Darebear
asked on
Change hyperlink NavigateURL
Hello.
When a user logs in I'm trying to change a Hyperlink NavigateURL based on their role. The code seems to work and the values get assigned to the hyperlink control if I debug the code but the actual Hyperlink on the page does not get refreshed. The hypelink and login control is is on my master page. How can I redraw or refresh the link?
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
If Roles.IsUserInRole(Login1. UserName, "Role1") Then
HyperLinkAdmin.NavigateUrl = "page1.aspx"
HyperLinkAdmin.Text = "Admin Role 1"
End If
If Roles.IsUserInRole(Login1. UserName, "Role2") Then
HyperLinkAdmin.NavigateUrl = "page2.aspx"
HyperLinkAdmin.Text = "Admin Role 2"
End If
When a user logs in I'm trying to change a Hyperlink NavigateURL based on their role. The code seems to work and the values get assigned to the hyperlink control if I debug the code but the actual Hyperlink on the page does not get refreshed. The hypelink and login control is is on my master page. How can I redraw or refresh the link?
Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn
If Roles.IsUserInRole(Login1.
HyperLinkAdmin.NavigateUrl
HyperLinkAdmin.Text = "Admin Role 1"
End If
If Roles.IsUserInRole(Login1.
HyperLinkAdmin.NavigateUrl
HyperLinkAdmin.Text = "Admin Role 2"
End If
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
are you using any ajax panel ?
ASKER
Nope, however it doesn't work if I do that either. I even placed the login control in the update panel also and that didn't work. I noticed also the hyperlink control isn't available in the trigger collection for the update panel. I tried also adding the login control to the update panel trigger collection and that didn't help either.
Does you Update panel has triggers?
By default, any postback control inside an UpdatePanel control causes an asynchronous postback and refreshes the panel's content. However, you can also configure other controls on the page to refresh an UpdatePanel control. You do this by defining a trigger for the UpdatePanel control. A trigger is a binding that specifies which postback control and event cause a panel to update. When the specified event of the trigger control is raised (for example, a button's Click event), the update panel is refreshed.
By default, any postback control inside an UpdatePanel control causes an asynchronous postback and refreshes the panel's content. However, you can also configure other controls on the page to refresh an UpdatePanel control. You do this by defining a trigger for the UpdatePanel control. A trigger is a binding that specifies which postback control and event cause a panel to update. When the specified event of the trigger control is raised (for example, a button's Click event), the update panel is refreshed.
<asp:UpdatePanel ID="UpdatePanel1"
UpdateMode="Conditional"
runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="<YourlogincontrolID>" />
</Triggers>
......
.....
...
..
.
</asp:UpdatePanel>
ASKER
Ramprathap, that's what I was saying in my last comment. I added the login control to the Asynchronous postback and it didn't refresh the link.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Aswer posted
ASKER
I think it's a matter of refreshing the control or redrawing it on the page so it becomes underlined and a valid hyperlink.