Reputation: 1675
i have an asp.net Button
, i want when a user click on that button:
if there is any Session["id"] for that user, user will be redirect to another page
2.if not show a PopupControlExtender and show some link to user
we cant use PopupControlExtender in code behind how i should check this condition ?
thx
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
<br />
<br />
<asp:Panel ID="Panel1" runat="server" BackColor="#9933FF" BorderColor="#6666FF"
Height="132px" Width="329px">
<asp:Button ID="Button2" runat="server" Text="Button" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Panel>
<asp:PopupControlExtender ID="PopupControlExtender1" runat="server"
TargetControlID="Button1" PopupControlID="Panel1"
>
</asp:PopupControlExtender>
</ContentTemplate>
</asp:UpdatePanel>
Upvotes: 1
Views: 2749
Reputation: 4903
What you can do is conditionally register some javascript for opening the Popup when the button is clicked.
Lets say you define your popup like this:
<ajax:PopupControlExtender ID="popup" runat="server"
TargetControlID="textbox"
BehaviorID="mybehavior"
PopupControlID="panel"
Position="Bottom" />
Then, on the button click event:
if(Session["id"] == null)
{
var script = @"Sys.Application.add_load(function() { $find('mybehavior').showPopup(); });";
ScriptManager.RegisterStartupScript(this, GetType(), "ShowPopup", script, true);
}
else
{
//Redirect;
}
Upvotes: 3