I have a webpart that pops up a jquery modal on page load. The modal prompts them to answer a question using a radio button list. They select an answer and click Answer (a modal button) which calls the btnAnswer onclick event. Code is below. The issue is that the page is posting back but the btnAnswer_Click event in the code fires but the radiobuttonlist doesn't have a selected value anymore. If I remove all JQuery references it works fine.

Webpart CreateChildControls

btnAnswer = new Button();
btnAnswer.ID = "btnAnswer";
btnAnswer.Text = "Answer";
btnAnswer.CssClass = "ms-buttonheightwidth";
btnAnswer.Click += new EventHandler(btnAnswer_Click);
btnAnswer.Style.Add("display", "none"); //javascript is handling clicking

Rendered output from the web part

<script language="javascript"> 
$(document).ready(function() {
bgiframe: true,
height: 300,
modal: true,
closeOnEscape: false,
width: 400,
buttons: {
'Skip': function() { if (confirm("Are you sure?")) {__doPostBack('ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$btnSkip','')}; },
'Answer': function() {__doPostBack('ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$btnAnswer','')}
</script><div id="dialog" title="Question" style="display:none"><span></span><span>What is the Capital of Massachusetts ?</span><table id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02" border="0">
                        <td><input id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_0" type="radio" name="ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$ctl02" value="1" /><label for="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_0">Boston</label></td>
                        <td><input id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_1" type="radio" name="ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$ctl02" value="2" /><label for="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_1">Springfield</label></td>
                        <td><input id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_2" type="radio" name="ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$ctl02" value="3" /><label for="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_2">Worcester</label></td>
                        <td><input id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_3" type="radio" name="ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$ctl02" value="4" /><label for="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_ctl02_3">Lawrence</label></td>
                </table><input type="submit" name="ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$btnAnswer" value="Answer" id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_btnAnswer" class="ms-buttonheightwidth" /><input type="submit" name="ctl00$m$g_583145bb_3463_40cc_b5ef_6f42c371f376$btnSkip" value="Skip Question" id="ctl00_m_g_583145bb_3463_40cc_b5ef_6f42c371f376_btnSkip" class="ms-buttonheightwidth" /><br/><br/></div>

3 Answers 3


I had a similar implementation , What i did was on the Answer click i called a webserivce and posted the value to the server.

  • Yeah, I can see that working. I am going to check out the ID idea below and probably use a webservice if this doesn't work. Thanks! Commented May 26, 2010 at 13:39

You haven't listed the CreateChildControls code for the creation of the radios in the group but, are they being recreated before you are attempting to use them (rehydrated from ViewState)? And have you set an implicit ID on the control group. By the looks of it (ctl02_1), you may not have, and this may be causing your problem.


  • I will take a look and we'll see. Commented May 26, 2010 at 13:39

I wonder if the jQuery dialog script treats your dialog div as a "template" and clones it, putting the cloned elements outside of the main form element, causing any input values not to be posted when the form is submitted.

Use IE Developer tools to inspect the DOM and use Fiddler to inspect what values are sent to the server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.