IT Community - Software Programming, Web Development and Technical Support

example of Server.Transfer and Context Handler

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > ASP and ASP.NET Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 09-03-2007, 12:25 AM
hanusoft hanusoft is offline
D-Web Trainee
 
Join Date: Sep 2007
Location: gurgaon
Posts: 5
hanusoft is on a distinguished road
Default example of Server.Transfer and Context Handler

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-06-2007, 07:08 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 1,061
S.Vinothkumar is on a distinguished road
Default Re: example of Server.Transfer and Context Handler

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>
page2.asp

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>
page3a.asp
Code:
<% @LANGUAGE="VBSCRIPT" %>
<h3>Step 3a - POST Results</h3>
<p>Hello <% = Request.Form("Name") %></p>
</body>
</html>
page3b.asp

Code:
<% @LANGUAGE="VBSCRIPT" %>
<h3>Step 3b - GET Results</h3>
<p>Hello <% = Request.QueryString("Name") %></p>
</body>
</html>
To try this example, save all pages to a Web folder with "Script" access enabled and browse "page1.asp."
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

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


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


All times are GMT -7. The time now is 02:37 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0