-1

Asp button is not working in a jquery dialog box:

<script type="txt/js">$(function () {$('#<%= ButtonEmail.UniqueID %>').button();});</script>

<div id="dialog-modal" title="Cadastro">
<p>Digite seu email para que eviemos o link do cadastro para ele:</p>
<p><asp:TextBox ID="TextBoxEmail" CssClass="ui-corner-all" runat="server"></asp:TextBox>&nbsp;&nbsp;
<asp:Button ID="ButtonEmail" runat="server" Text="Enviar Link" onclick="ButtonEmail_Click" /></p>
<div><asp:Label ID="LabelEmail" runat="server" Text="teste"></asp:Label></div>
</div>

c# code:

protected void ButtonEmail_Click(object sender, EventArgs e)
{
...
}

even when a delete this: $(function () {$('#<%= ButtonEmail.UniqueID %>').button();}); dont work, the button stays with the original design, but dont work

João Paulo
  • 6,300
  • 4
  • 51
  • 80
  • I think the .button function isn't working. It's supposed to provide visual enhancement to the input. Jquery UI I believe. However the OP really should let us know ;). – Kenneth Ito Jun 26 '12 at 04:48
  • please take a look at this answer: http://stackoverflow.com/questions/757232/jquery-ui-dialog-with-asp-net-button-postback – Muhammad Omar ElShourbagy Dec 12 '12 at 07:44

2 Answers2

0

may be something like this

var buttonId = <%= ButtonEmail.UniqueID %>; $(function () {$('#' + buttonId).button();});

haroonxml
  • 356
  • 1
  • 3
  • 14
  • you're storing the control id into `buttonId`, but when you try to use it, you're using a string and not the variable that you created... fail – MilkyWayJoe Jun 25 '12 at 20:58
  • yea true may be $(function () {$('#' + buttonId).button();}); – haroonxml Jun 25 '12 at 21:01
  • removed my -1 vote, but that's not the issue tho. This translates to the exact same thing the OP is doing, but nobody knows what the problem *really* is – MilkyWayJoe Jun 25 '12 at 21:03
  • I know but just trying to give an idea how something like that could be achieved thats why I used 'may be' – haroonxml Jun 25 '12 at 21:05
  • didnt work... :( even when a delete this: $(function () {$('#<%= ButtonEmail.UniqueID %>').button();}); dont work, the button stays with the original design, but dont work – João Paulo Jun 25 '12 at 23:07
  • is there anyway to recall the button event with click()? – João Paulo Jun 26 '12 at 00:08
0

Use this

<script type="text/javascript">
     $(function () {
          $('#<%= ButtonEmail.ClientID %>').button();
     });
</script>

Please note the ClientID which replaced UniqueId. Also ensure that the dependent scripts are loaded (There should be no javascript errors).

After reading some of the comments on the other answer, I'm starting to wonder if possibly it's your server side click event which is not working? In that case you're probably going to have to provide more information and code.

To make an asp.net server side click work in a dialog, ensure that the dialog is part of the form (after its been made into a dialog by jquery. Details are here. jQuery UI Dialog with ASP.NET button postback

Community
  • 1
  • 1
Kenneth Ito
  • 5,201
  • 2
  • 25
  • 44