Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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>
share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

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

share|improve this answer
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! –  David Lozzi May 26 '10 at 13:39
add comment

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.


share|improve this answer
I will take a look and we'll see. –  David Lozzi May 26 '10 at 13:39
add comment

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.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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