5

i have a page where on click of a button, a javascript function runs. It then aggregates some data and places the data on a hidden field in this page. It then opens a new window. This new window picks up this aggregated data like so :-

$('#accepted').val(window.opener.$('#accepted').val());

where accepted is the hidden field in both parent and child window (no runat="server" was used). The issue now is that i require this data to databind two grids. Currently I've done a doPostback on both grids, but what i really want to do is doPostback for the form once and handle the databinding the PageLoad event. So two questions :-

1) How do i doPostback the form?

2) How do i do this while still being able to differentiate from the actual form submission?

asked Jun 29, 2011 at 15:42

2 Answers 2

1

To post the form you should just be able to add a call to __doPostback in your javascript, after the accepted field is set. You can use the EventTarget and EventArgument parameters of the __doPostback to control the binding in your grid.

So, you could put this in your js:

__doPostback('rebindGrid', '');

and then this in your page load event:

if (Request.Form["__EVENTTARGET"] == "rebindGrid")
{
 //....Do so stuff
}
answered Jun 29, 2011 at 15:57
Sign up to request clarification or add additional context in comments.

Comments

0

In order to tie it in more directly with the postback model I wrap mine with some C#

C# Extension Method

public static string GetPostBackLink (this Control c, string argument = "") {
 return c.Page.ClientScript.GetPostBackEventReference(ctl, argument, true) + ";";
}

ASPX

<asp:LinkButton id="lnkDoThis" runat="server" onclick="lnkDoThis_Click" 
 style="display: none;"></asp:LinkButton>
<asp:HiddenField id="hdnParamHolder" runat="server" />

JS

function DoSomething(param) { 
 $("[id$='hdnDealTemp']").val(param);
 <%= lnkDoThis.GetPostBackLink() %> 
}

CodeBehind

protected void lnkDoThis_Click (object sender, EventArgs e) { 
 var myParam = hdnParamHolder.Value;
 // Do server actions here
}

As for the opening in a second window ... I am not sure I follow when you want this to happen? If it is after the postback you will need to read from the hdnParamHolder control when the page reloads.

answered Jun 29, 2011 at 16:23

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.