Difference between server.Execute and response.redirect ?
Answer Posted / manish kumar
Response.Redirect method :--------
it helps in navigating to another page from code. This is like clicking a hyperlink.To navigate from one page to another using button click or linkbutton control or from server side code use Response Object's Redirect method.
using Response.rediect() method u can not get information from source page on target page.
its source code is like
VB.Net Code
Private Sub Button1_Click(ByVal Sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
'Display target page.
Response.Redirect("Target.aspx")
End Sub
C# Code
private void Button1_Click(Object sender, System.EventArgs e)
{
//Display Target Page.
Response.Redirect("Target.aspx");
}
Using Server.Execute Method
use Server.Execute Method to process a Target web form without leaving the Source page. This technique let you embed the result from a target page to a region on Source page. Like Server.Transfer, It also required EnableViewStateMac attribute to page directive set to false.
Suppose I have to pages one is Calculate.aspx havinf two textboxes and a button control. On button Click event. I performed Server.Execute to Result.aspx another aspx page.
Source Code
protected void btn_Click(object sender, EventArgs e)
{
Server.Execute("Result.aspx");
}
Result.aspx page pageload event.
protected void Page_Load(object sender, EventArgs e)
{
NameValueCollection colform = new NameValueCollection();
colform = Request.Form;
Response.Write("<h2>Additon Result:</h2>" + (Convert.ToInt32(colform["TextBox1"]) + Convert.ToInt32(colform["TextBox2"])));
}
If any Mistake then suggest me...plz
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
I have created a configuration setting in my web.config and have kept it at the root level. How do I prevent it from being overridden by another web.config that appears lower in the hierarchy?
What is data cache in sql server?
Explain what is clr?
Why we use dbms for projects? Why don’t we save any application data in separate files instead of dbms?
Give me one example of Web API Routing?
How to implement role based security in asp.net mvc? : Asp.Net MVC
What events will occur when a page is loaded?
How many types of state management are there in asp net?
List some of the important session state modes of asp.net.
Why viewstate is used in asp.net?
Can you explain the importance of finalize method in .net?
How to reduce the width of textbox in editcommandcolumn of datagrid?
Can we have multiple master pages in asp net?
Differentiate between Server.Transfer and Response.Redirect with functionality? Why we can choose one over the other?
Is asp.net a programming language?