Thursday, March 29, 2012

List box forgets the items selected

Hi,

I am using a htmlinputbutton rather than webcontrols.button as i need to do server as well as client scripting. There is a list box whose items get submitted on click of this button. problem is that selected property of listitem works fine with webcontrol button click and does not works with htmlinputbutton_serverclick.
------------------
foreach (ListItem item in StepsListBox.Items)
{
if (item.Selected)
{
response.write(item.text);
}
}
---------------

Any ideas??

Thanks,
pradeepTry getting your items out of the Request.Form if you must use that Html button.
Thanks for the response.

Request.Form["listboxName"] does not seems to be working. It does not returns back the selected items.

I am ready to use webcontrols.button but problem is its server side click event does not gets called if i am calling javascript click function also using following code:
------------------
Button1.Attributes.Add("onClick","clientfunction");
------------------
I added this code in the page_load event.

Please help. I am stuck. I am not able to proceed neither with webcontrol button not htmlbutton. My aim is to call client as well as server script on button click, and i shud be able to get selected items of a listbox in the form on server side.

Thanks,
Pradeep
Your server-side could should still run when you add client-side JavaScript to the onClick. Try:

Button1.Attributes.Add("onClick", "JavaScript:clientFunction();");
Thanks again.

It worked this time. Problem was that i was disabling the controls in the client script and so server events were not firing.

But disabling controls is the requirement. I have to somehow show form busy and controls disabled until i get response from server. I am thinking now some another way to show form as busy.

thanks,
Pradeep

0 comments:

Post a Comment