PC Review


Reply
Thread Tools Rate Thread

Cross Page Posting in .net 2 Beta

 
 
jhoge123@yahoo.com
Guest
Posts: n/a
 
      14th May 2005
I would like to do a cross post from one page to another, but I have
two buttons on the main page, and I want the page receiving the post to
determine which button has been clicked:

<body>
<form id="form1" runat="server">
<div>
<asp:Button PostBackUrl="HandlerPage.aspx" ID="Button1"
runat="server" Text="Do This" /><br />
<asp:Button PostBackUrl="HandlerPage.aspx" ID="Button2"
runat="server" Text="Do Something Else" />&nbsp;</div>
</form>
</body>

HandlerPage.aspx can test Page.PreviousPage to see if it is being
called by a cross post, but how do I determine if Button1 or Button2
was clicked?

All I can think of right now are unpalatable options:
1) Clutter up the session object
2) Use a Querystring
3) Look at Request.form and check the ClientID of Button1 as below:

Button Button1 = (Button)PreviousPage.FindControl("Button1");
Button Button2 = (Button)PreviousPage.FindControl("Button2");
if (Request.Form[Button1.ClientID]==Button1.Text){
Response.Write ("Button1 CLicked");
}
else if (Request.Form[Button2.ClientID] == Button2.Text)
{
Response.Write("Button 2 Clicked");
}
}

This latter strategy seems to work, but I can't help thinking that
there must be a cleaner way.

 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      14th May 2005
You could add a client-side OnClick instruction to each button that sets a
hidden form field with a value. That value can then be tested in the
receiving page.


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I would like to do a cross post from one page to another, but I have
> two buttons on the main page, and I want the page receiving the post to
> determine which button has been clicked:
>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:Button PostBackUrl="HandlerPage.aspx" ID="Button1"
> runat="server" Text="Do This" /><br />
> <asp:Button PostBackUrl="HandlerPage.aspx" ID="Button2"
> runat="server" Text="Do Something Else" />&nbsp;</div>
> </form>
> </body>
>
> HandlerPage.aspx can test Page.PreviousPage to see if it is being
> called by a cross post, but how do I determine if Button1 or Button2
> was clicked?
>
> All I can think of right now are unpalatable options:
> 1) Clutter up the session object
> 2) Use a Querystring
> 3) Look at Request.form and check the ClientID of Button1 as below:
>
> Button Button1 = (Button)PreviousPage.FindControl("Button1");
> Button Button2 = (Button)PreviousPage.FindControl("Button2");
> if (Request.Form[Button1.ClientID]==Button1.Text){
> Response.Write ("Button1 CLicked");
> }
> else if (Request.Form[Button2.ClientID] == Button2.Text)
> {
> Response.Write("Button 2 Clicked");
> }
> }
>
> This latter strategy seems to work, but I can't help thinking that
> there must be a cleaner way.
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cross page posting of data ArunDhaJ Microsoft ASP .NET 1 29th Apr 2008 12:39 AM
Cross Page Posting using public property on previous page =?Utf-8?B?dGhlV2l6YXJkMQ==?= Microsoft ASP .NET 2 20th Apr 2006 09:27 PM
How to handle cross-page posting problem? =?Utf-8?B?QW5kcmV3?= Microsoft ASP .NET 6 6th Dec 2005 08:44 AM
Cross Page posting problems asp.net 2.0 Bryan Microsoft ASP .NET 5 27th Oct 2005 09:57 AM
Cross Page Posting in .Net 2.0 WertmanTheMad Microsoft ASP .NET 0 28th Sep 2004 03:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:01 PM.