Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Show jQuery Modal Popup from Code behind (Server Side)

May 5, 2014
Introduction

Here I will explain how to show
jQuery ui modal popup from code behind or open jQuery modal popup from server side in asp.net using c#, vb.net.

Description:
  
In previous articles I explained Show alert message from code behind, jQuery show alert message while leaving from website,
jQuery enable / disable controls on page, jQuery Countdown timer script example, jQuery Increase or Decrease font size of website and many articles relating to JQuery and asp.net. Now I will explain how to show jQuery ui modal popup from code behind or from server side in asp.net using c#, vb.net.

To show modal popup from code behind we need to write the code like as shown below


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Show Modal Popup from code behind or server side</title>
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
function showmodalpopup() {
$("#popupdiv").dialog({
title: "jQuery Popup from Server Side",
width: 430,
height: 250,
modal: true,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="popupdiv" title="Basic modal dialog" style="display: none">
<b> Welcome to Aspdotnet-Suresh.com</b>
</div>
<asp:Button ID="btnShowModal" runat="server" Text="Show Popup" OnClick="btnShowModal_Click" />
</div>
</form>
</body>
</html>
In code behind we need to write the code like as shown below

C# Code


protected void btnShowModal_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, GetType(), "Show Modal Popup", "showmodalpopup();", true);
}
VB.NET Code


Protected Sub btnShowModal_Click(ByVal sender As Object, ByVal e As EventArgs)
ScriptManager.RegisterStartupScript(Me, [GetType](), "Show Modal Popup", "showmodalpopup();", True)
End Sub
Demo



If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

6 comments :

Anonymous said...

great!!!!!

Anonymous said...

good

Tlungvel Vengthar KTP said...

Can you show this modal based on query result

Anonymous said...

Jab me ish popup me asp button add kr rha hu to wo kam nhi kr rha h server side hit nhi kr pa rha h...

smarklespr said...

aaaa

Unknown said...

close button not working

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.