Ich bin neu in C# und JQuery. Ich versuche, jQuery zu einem C# WebForm-Projekt hinzuzufügen. Was ich tun möchte, ist dies: Hinzufügen einer Schaltfläche zu einem Webformular. Wenn diese Schaltfläche serverseitig geklickt wird, dann wird eine JQuery-Dialogbox angezeigtC# jquery einfache Dialogbox
Dies ist der Code, den ich habe - wenn ich auf die Schaltfläche klicke passiert nichts. Ich frage mich, wo das Problem ist ....
ASPX-Datei:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="frmMain.aspx.cs" Inherits="Dialog_YES_NO_mit_JQuery.frmMain" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js' type="text/javascript"></script>
<script type="text/javascript">
function ShowPopup(message) {
$(function() {
$("#dialog").html(message);
$("#dialog").dialog({
title: "jQuery Dialog Popup",
buttons: {
Close: function() {
$(this).dialog('close');
}
},
modal: true
});
});
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
Dialogbox using JQuery<br />
<br />
<asp:Button ID="btnDemo1" runat="server" OnClick="btnDemo1_Click" Text="Demo1" />
<br />
</div>
</form>
</body>
</html>
aspx.cs Datei:
public partial class frmMain : System.Web.UI.Page
{
protected void btnDemo1_Click(object sender, EventArgs e)
{
string message = "Message from server side";
//ClientScript.RegisterStartupScript (this.GetType(), "Popup", "ShowPopup('" + message + "');", true);
ClientScript.RegisterClientScriptBlock(this.GetType(), "Popup", "ShowPopup('" + message + "');", true);
}
}
}
diesen Link finden> http://stackoverflow.com/questions/24917243/recommendation-for-simple-jquery-dialog-example – user2148124