ASP.NET: How to redirect, prefilling form data? -


I want to redirect a handler to a web-form page, filling up the values ​​of some controls on the form.

I present my current request Form : Try setting the data:

  if (wavattoodo something) {// prefill form value reference. Request Form ["Textbox 1"] = "Test"; Context.Request.Form ["ComboBox1"] = "Test 2"; Context.Request.Form ["TextBox2"] = GetTheTextForTheThing (); // Ask the client to go there. response. Redirect ("~ / SomeWebForm.aspx"); Return; }  

But I get an exception that the form values ​​are read only.

What would be one way to send the customer to another page, data to fill out the form?


Answer

I used the session to store the prices. It is important to note that by default handler will not have access to Sessions (session object null ). Object by adding the marker interface of your handler class:

  Public class handler: IHttpHandler, System.Web.SessionState.IRequiresSessionState {Public Zero processrequest (HttpContext reference) {... if (theyWantToDoSomething ) {// Pre-form Form Value Reference. Session ["thing1"] = "test"; Reference. Session ["talk2"] = "test2"; Reference. Session ["talk 3"] = GetTheTextForTheThing (); // Ask the client to go there. response. Redirect ("~ / SomeWebForm.aspx"); Return; // is not strictly necessary, because the redirect ends in the processing} ...}}  

You can only pop your response, the request is input data and in fact it is only read

If you are using ASP.NET, in many ways you can What can be achieved:

  • The best way is probably the data that you can get from pre-popping with someWebForm.aspx through SaveObject. Minister requires, and the load method on pages to populate your form. Keep in mind that when you respond. Redirect, a 302 response is sent to the client to the client, according to which the client should be redirected. This process is transparent to the user ... but includes a full round trip.

  • Another option for populating users is to add some parameters through a query string to the GET parameter on some WebForm.aspx redirects.

  • If you need to transfer processing to some WebForm.aspx page without some tripping, you can use the server. Transfer this page from the current page to which you Selects, will move execution for it ... However, this customer can cause some strange behavior on the end because the URL does not get updated. As far as the user is concerned, it will still appear as they are on the same page they started on.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -