I have a child page LoginContent.aspx which contains a login form. If the user logs in he should be redirected to my Welcome.aspx page. But if I press the login button the page just reloads itself, nothing happens. The codebehind on this page is empty. Both LoginContent.aspx and Welcome.aspx are child forms of the same master page.
<form method="post" action="~/Welcome.aspx">
Username: <input type="text" name="username" size="15" /><br />
Password: <input type="password" name="passwort" size="15" /><br />
<input type="submit" value="Login"/></p>
&l开发者_如何学Pythont;/form>
I know I could use the asp.net login control but I want more control over things.
You can't have nested form inside aspx page.
UPDATED:
Since ASP.NET webform doesn't allow us to have multiple form in one aspx page, thus in order to make it works, do the following:
- Remove the form tag
- add runat server to
- the input perform redirect in the server side
.
Username: <input type="text" name="username" size="15" runat=server /><br/>
Password: <input type="password" name="passwort" size="15" runat=server /><br/>
<input type="submit" value="Login" runat=server onclick="submit_onclick" /></p>
And in the code behind:
protected void submit_onclick(object sender, Event e)
{
// do some auth stuff here
Response.Redirect("~/welcome.aspx");
}
Hope this will answer your question.. :)
If your <form>
tag from your LoginContent.aspx nested inside your <form runat="server">
I would try moving it so it sits outside the server-side form and see if it works from there.
It might be worth tracking the HTTP requests in the Net panel of Firebug as well, just so you can see if it is actually making the HTTP POST request to /Welcome.aspx - it might help you pinpoint exactly where the problem is.
精彩评论