views:

328

answers:

1

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

A: 

are your functions inside the pageLoad javascript event that updatepanel calls each time it updates?

Bless Yahu
As I mentioned above the Javascript works fine and add and removing items from listbox client side.I have a another button on the page which will call Postback and load some values from database.There is the cause,If I try to add and delete from the existing List once again after postback happened it gives me an error.I have read through couple of website that IT would be Partialling loading of webpage and The Listbox control is loosing its state.I have changed few codes and calling ICallback Interface funcationality to avoid postback but on one event I really need a Postback.Plz Help.
DBMaster