-1

I have created a Webform which will be posted to another Webform after executing the server side code(C#).

I want to execute server code and based on the result of that I want to post the Webform to another Webform otherwise Webform should not be posted.

So, What should i do to achieve the above result?

Thanx in advance.

Crab Bucket
  • 6,219
  • 8
  • 38
  • 73
Dev Kashyap
  • 425
  • 1
  • 5
  • 6

1 Answers1

2

Do you mean redirect to another page?

If so:

In your Page_Load event use the following:

var basedResult = DoMyServerCode();

if (basedResult)
{
   Response.Redirect("~/YourOtherPage.aspx");
}
else
{
   // Load this forms data.
}

Added

Passing values between page (MSDN)

Lloyd Powell
  • 18,270
  • 17
  • 87
  • 123
  • I have to post data as well. Which is not possible with Response.Redirect without querystring. – Dev Kashyap Dec 19 '11 at 12:34
  • If you want to maintain data across pages, use a `Session` or a `Query String`. Keep it in mind that a `Session` will time out, so I would try and avoid it if there will be a user determined period of time, but if your setting it on the page leave and getting it on the other pages load then it will be fine as they are simultaneous. – Lloyd Powell Dec 19 '11 at 12:36
  • Sir, QueryString is secure way to pass sensitive data and We are posting form to another website so no chance for session. – Dev Kashyap Dec 19 '11 at 12:38
  • Query String is **not** a secure way to pass sensitive data. – Lloyd Powell Dec 19 '11 at 12:44
  • @DevKashyap it looks like you want to look in to HttpWebRequest (which is pretty old school) - http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx – Lloyd Powell Dec 19 '11 at 12:45
  • @DevKashyap the second answer here may be helpful - http://stackoverflow.com/questions/46582/response-redirect-with-post-instead-of-get – Lloyd Powell Dec 19 '11 at 12:47