Displaying a pop-up warning message on click checkbox in asp.net
I have an asp webpage. One of the elements in that asp page is an asp:repeater element as below:
<asp:repeater ID = repeater1 runat="Server" onitemdatabound="Repeater_ItemdataBound">
<ItemTemplate>
<div class="row1">
<span class="features">
<asp:checkbox id="cb1" runat="server" />
<asp:textbox id="tb1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Text") %> />
</div>
</ItemTemplate>
When the user clicks on the "checkbox", a warning message should pop-up asking whether user really wants to sel开发者_开发百科ect. The contents on the warning message, come from the data that is bound to the repeater. DataItem has a property "WarningText". The pop-up should appear only in certain cases when the warning message is not null.
I have very little experience with asp. I am not sure what should I be even looking for, if i had to find some online resources for this problem. I think I would have to use some client side scripting like javascript for this, but i do not know anything else. I would appreciate if someone can point me in right direction.
Add this to the checkbox:
<asp:checkbox id="cb1" runat="server" onclick="return confirm('<%# DataBinder.Eval(Container.DataItem, "WarningText") %>');" />
If the question you are asking is something like "How could I create a pop up message?" You could try looking into JQuery Dialog.
It would not be very hard to implement client or server side. If you need to determine if the pop up is showing server side you can use an asp:Placeholder
with a nested dialog div inside it.
If you wanted to do it server side you can either do an onclick
(if asp checkboxes have that) or add other functionality that will create a dialog.
If you already have text created and just need to know how to make it visible server side you can use asp:Placeholder
s and do something like this:
HTML
<asp:Placeholder ID = "placeHolder"> ....
Code behind:
placeHolder.Visible = true/false;
(visible may be lowercase)
Hopefully that helps. Sorry if it doesn't, I was kind of having a hard time figuring out the question.
Protected Sub JavaAlert(ByVal strMsg As String)
Dim alertScript As String = "<script language='javascript'>alert('" & strMsg & "')</script>"
Page.ClientScript.RegisterStartupScript(GetType(Page), "PopupScript", alertScript)
End Sub
精彩评论