×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jquery Dialog Form

Jquery Dialog Form

Jquery Dialog Form

(OP)
I have the following code which opens up a form in a jquery dialog.

CODE

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="dialog.aspx.vb" Inherits="dialog" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
<link href="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-darkness/jquery-ui.css" rel="stylesheet">
	<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
</head>
<body>
<form runat="server">
    <div id="dialog" title="Dialog">
		
        
        <table>
        <tr>
        <td>Name:</td>
        <td></td>
        </tr>
            
        <tr>
        <td>Email Address:</td>
        <td></td>
        </tr>
        
        
        </table>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        




	</div>
    <input type="button" id="button" value="Click to open the dialog">
	<script>
	   
	    $(function () {
	        $("#dialog").dialog({
	            autoOpen: false
	        });
	        $("#button").on("click", function () {
	            $("#dialog").dialog("open");
            
	        });

	    });
	</script>
    </form>
</body>
</html> 

I have some .net code on the Button1 which adds a new record to the database, however whenever I click on the button it doesn't fire the event.

Also I need it to close the dialog form as well.

Any ideas.
Thanks
Andrew

RE: Jquery Dialog Form

I think that may be old jquery syntax.
Try

CODE

$("#button").click(function () {
  $("#dialog").dialog("open");
}); 

RE: Jquery Dialog Form

Humm, ok not old syntax... my bad
put the script at the top of the page and try it.

RE: Jquery Dialog Form

it looks like the jquery selector is looking for an element with the id "button", but the actual element's id is "Button1".

good luck!

-Mark

RE: Jquery Dialog Form

Good catch Mark!

RE: Jquery Dialog Form

(OP)
Hi, thanks for your help.

I managed to get it working with

CODE

<script type="text/javascript">
	    $(document).ready(function () {
	        $("#dialog").dialog({ autoOpen: false, modal: true, width: '400px', title: "Add New Item"  })
	        $("#AddNew").click(function () {
	            $("#dialog").dialog('open');
	            return false;
	        });

	        $('#<%= AddNewButton.ClientID %>').click(function () {
	            __doPostBack('<%= AddNewButton.ClientID %>', '');
                $("#dialog").parent().appendTo(jQuery("form:first"));
	            $("#dialog").dialog('close')
	        });
	    });
</script> 

RE: Jquery Dialog Form

(OP)
Any idea why the code on my button would be firing twice.

I have code that inserts a record into a table and it adds the record twice.

RE: Jquery Dialog Form

I would imagine it's because you are manually triggering a postback. An asp.net button, by default, already triggers a postback.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close