UpdatePanel Javascript Error on Adding Clientside Listbox items After postback
Posted
by DBMaster
on Stack Overflow
See other posts from Stack Overflow
or by DBMaster
Published on 2010-04-01T13:59:42Z
Indexed on
2010/04/01
14:03 UTC
Read the original article
Hit count: 379
Hi,
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 code 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
© Stack Overflow or respective owner