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 custom form in my SharePoint 2010 site. There a couple of things to note here:

  1. My custom form is in a SharePoint modal dialog

  2. I have a 2nd modal dialog that prompts the user if they "really" want to save a duplicate record

In the first dialog, a user will type in a bunch of information. If they type a duplicate record, in the 2nd modal dialog, they will be asked if they want to save a duplicate record. If they answer yes, I need to go back to the first modal dialog, do a postback and save the information they entered. The trouble I'm having is that I cannot get the form to postback to the server side code to actually save the record. Can someone help? Below is my code, but if someone wants to show me a different way, I am open to that.

Markup for the dialog modal.

<div id="hiddenDuplicateErrorMessage" style="display: none;">
<p style=" padding: 5px; font-size: 11pt;">You are attempting to create an award    
that matches an existing award in the Awards Tracking System.
 If this is a unique award submission, click 'Submit' to continue with the award   
submission, or 'Cancel' to return to your award form to revise 
 your submission.</p>
<p style="width: 100%; text-align: right;">
    <button id="btnSubmitDuplicateAward" 
onclick="javascript:doPostBack('<%=btnSubmitFormConfirmed.ClientID %>','')" 
type="button">Submit</button>
    <button id="btnCancelDuplicateAward" type="button">Cancel</button>
</p>
</div>
<div style="display:none;"><asp:Button ID="btnSubmitFormConfirmed"    
OnClick="btnSubmitFormConfirmed_Click" runat="server" /></div>

<input type="hidden" name ="__EVENTTARGET" value ="" />
<input type="hidden" name ="__EVENTARGUMENT" value ="" />

Javascript Code for the confirmation dialog

function doPostBack(eventTarget, eventArgument) {
document.aspnetForm.__EVENTTARGET.value = eventTarget;
document.aspnetForm.__EVENTARGUMENT.value = eventArgument;
document.aspnetForm.submit();
}

Code Behind that checks to see if a duplicate and creates the prompt to confirm saving a duplicate.

if (duplicateAward)
ClientScript.RegisterStartupScript(this.GetType(), "ShowDelayedErrorMessage",   
"ExecuteOrDelayUntilScriptLoaded(function () { var myControl =   
$('#hiddenDuplicateErrorMessage').html(); openDialog(null, 'Error Creating Award',  
myControl); }, 'sp.ui.dialog.js');", true); 
share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.