I have a delete and update button that launches a popup. In the popup I have a label that says Are you sure you want to ” ” I want to use to text from the button the user push and place it into that ” ” area.
ie if they push update, label would say “are you sure you want to update?” and vice versa for delete.
To my knowledge, I can not hide two labels and only use one when one button is clicked because it is position in a div that is running a javascript .show / .hide event. Thus anything that is hidden in that div would automatically appear on that command.
Any suggestions on making a dynamic label that retrieves the text of a button?
javascript
function popup() {
$("#popupbg").animate({ opacity: ".8" });
$("#delete").click(function() {
$("#popupbg, #popupbgitembg").show('fast')
});
}
function popupcancel() {
$("#popupbg, #popupbgitembg").hide('medium');
}
function popupdel() {
var button = document.getElementById("<%= execdelete.ClientID %>");
button.click();
$("#popupbg, #popupbgitembg").hide('medium');
}
html
<div id="popupbg">
</div>
<div id="popupbgitembg">
<ul class="popupbgitems">
<li>
Are you sure you want to delete?
</li>
<li></li>
<li>
<asp:Button ID="execdelete" runat="server" CssClass="invisible" OnClick="delSysGLDepts" />
<asp:Button ID="butdelete" runat="server" Text="Delete" OnClientClick="javascript:scroll;popupdel();" Font-Size="11px"/>
<asp:Button ID="butcancel" runat="server" Text="Cancel" OnClientClick="javascript:popupcancel();" Font-Size="11px"/>
</li>
</ul>
</div>
Because you haven’t shown any sample code I can only discuss in theory, but yes there is no reason you can’t accomplish this.
I’m assuming you are using javascript
confirmto show the alert? If so you can get the text of the button either clientside through javascript or serverside through your code-behind (again I don’t know if your button is client or serverside because you don’t have any sample code). Take that text and pass as part of the text in your confirm call. That should do it.If you post some actual code it would be easier to be more specific, but the above concept should work just fine.