| | |
Its not redirecting to the same page
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 32
Reputation:
Solved Threads: 1
I am making a form and at the end of the form there is a save btn that should save data into database and redirect the page the same page that the form is in. Well its not working.
simply speaking its just
Response.Redirect("samepage.aspx");
I know it should work, but all what i get is "Internet Explorer cannot display the webpage"
anyone knows whats going on here!!
anyway thanks for helping inadvance.
simply speaking its just
Response.Redirect("samepage.aspx");
I know it should work, but all what i get is "Internet Explorer cannot display the webpage"
anyone knows whats going on here!!
anyway thanks for helping inadvance.
??
Usually in ASP.NET you don't cross post to different pages like in the classic ASP days. With ASP.NET the form POSTS to itself by default. So you don't need a re-direct unless you need to go to a different aspx page or resource. In fact re-directing to the same page is a very bad thing to do because it will cause a double request to the server for the same page !
browser -> requests samepage.aspx (POST)
server -> processes POST, hits the re-direct and sends browser a re-direct message
browser -> requests samepage.aspx (GET)
server -> supplies page
Instead of
browser -> requests samepage.aspx (POST)
server -> processes POST, supplies page.
Your error suggests to me you have misspelled the page name, or the page is in a sub/parent path.
Usually in ASP.NET you don't cross post to different pages like in the classic ASP days. With ASP.NET the form POSTS to itself by default. So you don't need a re-direct unless you need to go to a different aspx page or resource. In fact re-directing to the same page is a very bad thing to do because it will cause a double request to the server for the same page !
browser -> requests samepage.aspx (POST)
server -> processes POST, hits the re-direct and sends browser a re-direct message
browser -> requests samepage.aspx (GET)
server -> supplies page
Instead of
browser -> requests samepage.aspx (POST)
server -> processes POST, supplies page.
Your error suggests to me you have misspelled the page name, or the page is in a sub/parent path.
Last edited by hollystyles; Feb 25th, 2008 at 7:19 am.
•
•
Join Date: Nov 2007
Posts: 32
Reputation:
Solved Threads: 1
Thanks hollystyles for helping, but its not spelling mistake and the page is in the same directory. All what I wanted to do is to make the form reappear with empty fields?
Well I thought of something.
I can remove the redirecting, the page will reappear, but the fields are not empty.
I can make them empty manually, by giving the text fields empty strings.
I am not sure if this is a proffesional way!!??
Any suggestions.
Well I thought of something.
I can remove the redirecting, the page will reappear, but the fields are not empty.
I can make them empty manually, by giving the text fields empty strings.
I am not sure if this is a proffesional way!!??
Any suggestions.
Last edited by Jihad; Feb 25th, 2008 at 7:52 am.
You can disable viewstate for the page so the controls don't keep their values between postbacks.
or
After having saved to the database
Just itertate the controls and set their property .Text = String.Empty; in the code.
or
After having saved to the database
Just itertate the controls and set their property .Text = String.Empty; in the code.
•
•
Join Date: Feb 2008
Posts: 85
Reputation:
Solved Threads: 3
hiii,,,,well u can clear the textboxes on the click of the save button
like::::: TextBox1.text="";
if the insert query is properly fired thn u can use the above code..for e.g.
_______________
private void Button1_Click(object sender, System.EventArgs e)
{
create a connection///
try{
sql command ins = new sql command("insert statement......")
if (ins.ExecuteNonQuery()>0)
{
textbox1.text="";
}
else{......}
}
catch{......}
}
__________________________________
try it ,,,hope it wil wrk for u
like::::: TextBox1.text="";
if the insert query is properly fired thn u can use the above code..for e.g.
_______________
private void Button1_Click(object sender, System.EventArgs e)
{
create a connection///
try{
sql command ins = new sql command("insert statement......")
if (ins.ExecuteNonQuery()>0)
{
textbox1.text="";
}
else{......}
}
catch{......}
}
__________________________________
try it ,,,hope it wil wrk for u
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- Removing Query Strings (ASP.NET)
- how to transfer large data to one page to another page (ASP.NET)
- Can't access to hotmail page :(( (Web Browsers)
- PHP Form mailing troubles (PHP)
- Redirecting images depending on the page they are displayed on. (Linux Servers and Apache)
- Diggler: Page cannot be displayed (Web Browsers)
- page.php?page=1,2,3,4,..inf. (PHP)
Other Threads in the ASP.NET Forum
- Previous Thread: Object reference not set to an instance of an object
- Next Thread: retrieving ID's
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net beginner bottomasp.net box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv form forms gridview gudi homeedition hosting iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings redirect registration relationaldatabases rotatepage search security select serializesmo.table sessionvariables silverlight smartcard sql ssl tracking treeview typeof validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopment wizard xml xsl






