Q
Problem solve Get help with specific problems with your technologies, process and projects.

When I submit my form, the original page loads instead of my new code

Sorry if this is a simple question, but I am new to ASP.NET and this is bugging me. I have created a simple form with a defined action to load a different page. However, whenever I click the submit button on the form, the original page loads. And when I look at the created source code, the action I put in has been replaced the name of the original page. Help, please!
In ASP.NET, server-side forms (with attribute runat=server) always "point" to themselves. This is called a postback. The way ASP.NET works assumes the form will be posted to itself, so that any server-side code can be executed for that page.

You should add a button Web control to the page, double-click it, and write something like the following in the code-behind page that will open for the click (server-side) event handler:

private void btnTransfer_Click(object sender, EventArgs e)
{
//Redirection is performed on the server.
	Server.Transfer(?target.aspx?);  	
//or normal HTTP redirection on the client:
Response.Redirect(?target.aspx?);
}

Dig Deeper on Win Development Resources

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

TheServerSide.com

Close