Design the form as follows:
<head runat="server">
<title></title>
<script src="jquery-1.7.min.js"></script>
</head>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnjquery" runat="server" Text="callingjquerycode" OnClick="btnjquery_Click" />
</div>
</form>
.cs page:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnjquery_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append("$(document).ready(function(){");
sb.Append("alert('hi welcome to this world.');");
sb.Append("});");
Page.ClientScript.RegisterStartupScript(this.GetType(), "Script",sb.ToString(), true);
}
Output:
<head runat="server">
<title></title>
<script src="jquery-1.7.min.js"></script>
</head>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnjquery" runat="server" Text="callingjquerycode" OnClick="btnjquery_Click" />
</div>
</form>
.cs page:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnjquery_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append("$(document).ready(function(){");
sb.Append("alert('hi welcome to this world.');");
sb.Append("});");
Page.ClientScript.RegisterStartupScript(this.GetType(), "Script",sb.ToString(), true);
}
Output:
No comments:
Post a Comment
Thank you for visiting my blog