UpdatePanel Javascript Error on Adding Clientside Listbox items After postback
I have a Dynamic list control of Metabuilder.Webcontrol inside UpdatePanel,I am adding removing Items using Javascript from the list control. It works fine Inside UpdatePanel.
I have another control Gridview along with checkbox's which require postback to get populated.
Once It gets populated successfully inside update without postback. I checked few rows and wanted to add them into List Control using Javascript.
It says "object doesn't support this property or method"
function addItmList(idv,valItem) {
var list =document.getElementById('ctl00_ContentPlaceHolder1_MyList');
//var generatedName = "newItem" + ( list.options.length + 1 );
list.Add(idv,valItem);
}
function checkitemvalues()
{
var gvET = document.getElementById("ctl00_ContentPlaceHolder1_grd");
var target = document.getElementById('ctl00_ContentPlaceHolder1_lstIControl');
var newOption = window.document.createElement('OPTION');
var rCount = gvET.rows.length;
var rowIdx = 0;
var tcount = 1;
for (rowIdx; rowIdx<=rCount-1; rowIdx++) {
var rowElement = gvET.rows[rowIdx];
var chkBox = rowElement.cells[0].firstChild;
var cod = rowElement.cells[1].innerText;
var desc = rowElement.cells[2].innerText;
if (chkBox.checked == true){
addItmList(rowElement.cells[1].innerText,rowElement.cells[2].innerText);
}
}
}
Code Behind
ScriptManager.RegisterClientScriptBlock(
Me.Page, Me.GetType(), MyList.ClientID, "" & vbCr & vbLf & "window.mylistid='" + MyList.ClientID + "';" & vbCr & vbLf & "", True )
Remember my c开发者_运维知识库ode works fine. It cannot maintain the state of List Control thats why It says Object reqiured.
Can any one help me out. After Update Panel Why My javascript doesnt add Items into ListBox.
Thanks In advance
are your functions inside the pageLoad javascript event that updatepanel calls each time it updates?
精彩评论