I am having a login status inside login view control which is in the master page and when I click login I need to show the login control which is in the ajax update panel without refreshing the page.
When the Default page is loading and when I click the login status the page is directing to login page instead of updating the Update Panel.
Can anyone help me in this issue?
Here is code for Default.aspx:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:LoginStatus ID="LoginStatus1" runat="server"
LogoutAction="RedirectToLoginPage" LogoutPageUrl="~/Login.aspx" />
</AnonymousTemplate>
</asp:LoginView>
开发者_C百科 <asp:Login ID="Login1" runat="server">
</asp:Login>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Login1" />
</Triggers>
</asp:UpdatePanel>
Here is the code for Default.aspx.vb:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.load
If Not Me.IsPostBack Then
UpdatePanel1.Visible = True
Else
UpdatePanel1.Visible = False
End If
End Sub
Guess there's an option in web config where you specify the login url when using the login control of asp.net. Make sure nothing like that is there in your web config.
Dont't make the update panel invisible. Don't do anything with the updatepanel in code behind. UpdatePanel is not itself visible it's just a container that helps you get asynchronous postback.
Instead keep login1 hidden and when you click login status make it visible in the .click event of login status button in your code behind.
Or just put your login control in a div or panel and make this panel hide and show.
加载中,请稍侯......
精彩评论