I need to create a radiobuttonlist containing a “other” option, and i have to put a textbox next to it. Here is what i did.
if(!ispostpage){
PlaceofWork.DataSource = workplace;
PlaceofWork.DataBind();
PlaceofWork.DataTextField = "WorkPlace1";
PlaceofWork.DataValueField = "WorkID";
PlaceofWork.Items.Add(new ListItem("Other - Specify<input name=\"OtherWorkPlace\" type=\"text\" value=\"test\" id=\"OtherWorkPlace\"/>", "-1"));
This radiobuttonlist is in a usercontrol.
at the first I didn’t add if(!ispostpage) so when i try Request.Form["OtherWorkPlace"], it didn’t return anything
after i add the code if(!ispostpage), it pop up the error “Object reference not set to an instance of an object”
So how can I get the value of the input textbox?
You could use a hidden field control on the asp .net side.
The set the value of the control using a javascript onblur event.
Then in the code behind just reference the HiddenField.