This is a discussion on example of Server.Transfer and Context Handler within the ASP and ASP.NET Programming forums, part of the Web Development category; This is an example of Server.Transfer and Context Handler. Through this we can get the multiple values of previous ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| This is an example of Server.Transfer and Context Handler. Through this we can get the multiple values of previous form. In this page we are displaying data from previous form. We can use this technique for multiple form registration form. Code (ContextParent.aspx.cs): - private void Button1_Click(object sender,System.EventArgs e) { Server.Transfer("ContextChild.aspx"); } internal Hashtable Value { get { Hashtable objHT = new Hashtable(); objHT["Name"]=TextBox1.Text; objHT["FathersName"]= TextBox2.Text; objHT["Address"] = TextBox3.Text; return objHT; } } Code (ContextChild.aspx.cs) :- private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here Hashtable objHT = new Hashtable(); if(!IsPostBack) { ContextParent ParentPage; ParentPage = (ContextParent)Context.Handler; objHT = ParentPage.Value; Response.Write("<br><br>"); foreach(DictionaryEntry di in objHT) { Response.Write(di.Key +" : "+di.Value); Response.Write("<br>"); } } }
__________________ Offshore Software Last edited by Booom : 11-12-2007 at 05:11 AM. |
| Sponsored Links |
| |||
| Hi Here is a sample for Server.Transfer....Go thru this... In this example, the starting page contains two forms, one using the HTTP POST method and the other using the HTTP GET method. Both pages use the same second page that detects the HTTP method and transfers to a different third page for each method used. Because the transfer method is being used, the Request Object is still populated and the correct results from the first page are displayed on the respective third page. page1.asp Code: <html>
<body>
<h3>Step 1 - Form Page</h3>
<table border="1">
<tr>
<th>POST</th>
<td>
<form action="page2.asp" method="POST">
<input type="text" name="Name">
<input type="submit" value="Submit">
</form>
</td>
<tr>
</tr>
<th>GET</th>
<td>
<form action="page2.asp" method="GET">
<input type="text" name="Name">
<input type="submit" value="Submit">
</form>
</td>
</tr>
</table>
</body>
</html> Code: <% @LANGUAGE="VBSCRIPT" %>
<html>
<body>
<h3>Step 2 - Transfer Page</h3>
<%
Select Case UCase(Request.ServerVariables("REQUEST_METHOD"))
Case "POST"
Server.Transfer "page3a.asp"
Case "GET"
Server.Transfer "page3b.asp"
Case Else
Response.Write "An unknown HTTP verb was used."
End Select
%>
</body>
</html> Code: <% @LANGUAGE="VBSCRIPT" %>
<h3>Step 3a - POST Results</h3>
<p>Hello <% = Request.Form("Name") %></p>
</body>
</html> Code: <% @LANGUAGE="VBSCRIPT" %>
<h3>Step 3b - GET Results</h3>
<p>Hello <% = Request.QueryString("Name") %></p>
</body>
</html>
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is the difference between Server.Transfer and Response.Redirect?.. | H2o | ASP and ASP.NET Programming | 4 | 11-22-2007 05:25 AM |
| Difference between Server.Transfer and Response.Redirect | Arun | ASP and ASP.NET Programming | 4 | 09-19-2007 10:52 PM |
| Can I set up my own JavaScript error handler? | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 09-13-2007 03:07 AM |
| Can I disable the Windows context menu that normally shows up when the user clicks th | itbarota | HTML, CSS and Javascript Coding Techniques | 1 | 09-13-2007 02:16 AM |
| What is the difference between Server.Transfer and Response.Redirect? Why would I cho | prasath | ASP and ASP.NET Programming | 1 | 07-19-2007 02:41 AM |