Reputation: 1115
vb:
Protected Sub edit_content_Click(sender As Object, e As System.EventArgs) Handles edit_content.Click
MsgBox("dasfaf")
End Sub
asp:
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:LinkButton ID="LinkButton3" runat="server">LinkButton</asp:LinkButton>
<a href="#" class="table-actions-button ic-table-edit" id="create-user"></a>
</ItemTemplate>
</asp:TemplateField>
<div id="dialog-form" title="Edit Content" style="width:1001px;">
<div>
<asp:Button ID="edit_content" runat="server" Text="Edit Content" class="buttons" />
</div>
</div>
jquery:
$("#create-user").button().click(function () {
$("#dialog-form").dialog("open");
});
my problem is that i'm putting an asp button in the jquery form to be abel to do some code in vb when the button is clicked... but the problem is that when i click on the button it does not go to the click event... if i put the button outside the dialog everything works... but i need it in the dialog ...
so how can i manage that?
any suggestions?
Upvotes: 1
Views: 1717
Reputation: 3010
You need to change your jQuery to be like this:
$("#create-user").click(
function ()
{
var dlg = $("#dialog-form").dialog();
dlg.parent().appendTo($("form:first"));
});
I've tested it and it correctly calls the button click event server side.
Update: Here's the complete page I used to test this, this is in the default page created in an ASP.net application.
<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<script type="text/javascript" src="http://codeorigin.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://codeorigin.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<input id="create-user" type="button" value="button" />
<div id="dialog-form" title="Edit Content" style="width:1001px;">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</div>
<script type="text/javascript">
$("#create-user").click(
function () {
var dlg = $("#dialog-form").dialog();
dlg.parent().appendTo($("form:first"));
});
</script>
</asp:Content>
Code behind:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
End Sub
End Class
Upvotes: 1
Reputation: 643
Looks like it is an issue.
There is a workaround for this though.
Add the following Javscript code to the page/control.
function Test2() {
<%=Page.ClientScript.GetPostBackEventReference(edit_content, "")%>
}
And in your html add the javascript call:-
<asp:Button ID="edit_content" runat="server" OnClientClick="return Test2();" Text="Edit Content" class="buttons" />
It should work.
Upvotes: 0