Because of the Syncfusion Essential Studio Business Intelligence Edition's features, it comes with a price. And that is the only bad thing I have seen in this product until now.
Happy Coding.
Regards,
Jaliya
| Installing jQuery library |
| Installing jQuery UI library |
| Adding a theme |
<script src="Scripts/jquery-1.7.2.js" type="text/javascript"></script> <script src="Scripts/jquery-ui-1.8.20.js" type="text/javascript"></script> <link href="Content/themes/redmond/jquery-ui-1.8.22.custom.css" rel="stylesheet" type="text/css" />I am adding a div to my page, and it will be the modal.
<div id="dialog-alert" title="Message"> </div>I am writing a method in the code behind file which will contain the JavaScript function.
private void ShowJqueryMessage(string message) { try { //Initialize the stringbuilder object to append javascript StringBuilder sb = new StringBuilder(); sb.Append("$(function() { "); sb.Append("$('#dialog-alert').empty();"); sb.Append("$('#dialog-alert').append('" + message + "');"); sb.Append(" $('#dialog-alert').dialog({"); sb.Append(" width: 350,"); sb.Append("buttons: {"); sb.Append("'Close': function () {"); sb.Append("$('#dialog-alert').dialog('close');"); sb.Append("}"); sb.Append(" }"); sb.Append(" });"); sb.Append("});"); //Register the script on page startup ClientScript.RegisterStartupScript(typeof(Page), "myscript", sb.ToString(), true); } catch (Exception ex) { throw ex; } }Then in my button click event I am calling the method.
protected void Button1_Click(object sender, EventArgs e) { ShowJqueryMessage("Message."); }
| Message in the modal |
INSERT INTO TestTable VALUES (1, 'aaa');
INSERT INTO TestTable VALUES (2, 'bbb');
INSERT INTO TestTable VALUSE (3, 'ccc'); -- Syntax error.
SELECT * FROM TestTable ; -- Returns no rows.
INSERT INTO TestTable VALUES (2, 'bbb');
INSERT INTO TestTable VALUES (1, 'ccc'); -- Duplicate key error.
SELECT * FROM TestTable -- Returns rows 1 and 2.
<script src="Scripts/jquery-1.7.2.js" type="text/javascript"></script> <script src="Scripts/jquery-ui-1.8.20.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#dialog-page").dialog("destroy"); }); function showDialog(uniqueName) { $("#dialog-page").load('../NewPage.aspx').dialog({ autoOpen: false, resizable: true, height: 400, width: 600, modal: true }); $('#dialog-page').dialog('open'); return false; } </script>In your page which will have the the control to open the modal, add this div.
<div id='dialog-page' title="Modal"> </div>I am using Link Button to open the modal. This is how you can trigger the javascript function.
<asp:LinkButton ID = "lbtnModal" runat="server" Text="Open" OnClientClick="javascript:return showDialog(this.name);" ></asp:LinkButton>
![]() |
| New page inside the modal |
<div id="tabs"> <asp:HiddenField ID="tab_index" Value="0" runat="server" /> <ul> <li><a href="#tabs-1">Tab 1</a></li> <li><a href="#tabs-2">Tab 2</a></li> <li><a href="#tabs-3">Tab 3</a></li> </ul> <div id="tabs-1"> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click"/> </div> <div id="tabs-2"> <asp:Button ID="Button2" runat="server" Text="Submit" OnClick="Button2_Click"/> </div> <div id="tabs-3"> <asp:Button ID="Button3" runat="server" Text="Submit" OnClick="Button3_Click"/> </div> </div>
<script type="text/javascript"> $(document).ready(function () { var iSelectedTab = $(this).find("input[id*='tab_index']").val(); if (iSelectedTab == null) iSelectedTab = 0; $('[id$=tabs]').tabs({ selected: iSelectedTab }); }); </script>
Hope this helps.protected void Button1_Click(object sender, EventArgs e) { tab_index.Value = "0"; } protected void Button2_Click(object sender, EventArgs e) { tab_index.Value = "1"; } protected void Button3_Click(object sender, EventArgs e) { tab_index.Value = "2"; }
I have installed SharePoint 2013 and the user experience is some what different when comparing to SharePoint 2010, but it is great. It’s like Windows 8 user experience. I think it will take some time to get familiar with this new release and I am pretty sure it is worth it.
I am pretty sure that you can find many articles about how to connect to a specific database on a SQL Server instance in C#. But you won't be able to find many about how to connect to a specific SQL Server instance in C#. So thought to write a post about how to connect to a SQL Server Instance in C#.
Before starting off with the topic, I think it's better to refresh the knowledge in SQL Server instances.
using System;Hope this helps.
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
namespace ConnectToSQLInstance
{
class Program
{
static void Main(string[] args)
{
string username = "sa";
string password = "sa";
string instanceName = "instance_name";
string remoteSrvName = "remote_server_name";
/*----------------connect to default instance----------------*/
Server oServer = new Server();
// set to true for Windows Authentication
oServer.ConnectionContext.LoginSecure = false;
oServer.ConnectionContext.Login = username;
oServer.ConnectionContext.Password = password;
// connection is established
Console.WriteLine(oServer.Information.Version);
/*----------------connect to named instance----------------*/
ServerConnection oServerConnection = new ServerConnection();
// connects to named instance
oServerConnection.ServerInstance = @".\" + instanceName;
oServerConnection.LoginSecure = false;
oServerConnection.Login = username;
oServerConnection.Password = password;
Server oServerNamed = new Server(oServerConnection);
// connection is established
Console.WriteLine(oServerNamed.Information.Version);
/*----------------connect to default instance----------------*/
// In here remote server name / ServerInstance needs to be specified
ServerConnection oRemoteServerConnection = new ServerConnection(remoteSrvName);
oRemoteServerConnection.LoginSecure = false;
oRemoteServerConnection.Login = username;
oRemoteServerConnection.Password = password;
Server oServerRemote = new Server(oRemoteServerConnection);
// connection is established
Console.WriteLine(oServerRemote.Information.Version);
}
}
}
Isn't it nice to have some simple tool which will allow you to easily browse through your connected MS SQL Servers' all databases and tables? And then view the table information in design mode such as column names, column types, column sizes and primary keys etc? And finally to create "INSERT", "UPDATE", "DELETE" and "SELECT" stored procedures for a selected table in a single button click?
Since I am little bit lazy in doing things related to MS SQL, I wanted an application to make my life easier when writing Stored Procedures and all. So I have wrote this simple tool, in which it's main task is to generate Stored Procedures which ultimately ended up as a "MS SQL Server table browser and a Stored Procedure Generator".
This tool has the ability to connect to default, named or remote instances of SQL Server database engine. (Please note that, only the SQL Server Authentication is supported in this version.) Then it can be used to browse databases and tables of connected SQL Server instance and then to view tables design in an easier manner. And finally it has the capability to generate "INSERT", "UPDATE", "DELETE" and "SELECT" stored procedures for a selected table.
![]() |
| Connect To Server |
![]() |
| Database and Table Browser |
![]() |
| Table Design Viewer |
![]() |
| Stored Procedure Generator |
I have uploaded the installer to my skydrive, so anyone can help themselves with this tool. I have ran couple of tests with generated stored procedures and the results were very much satisfying. But if you come across with any kind of bug, please let me know as I am planning to enhance this tool further. It is really appreciated.
Download
Happy Coding.
Regards,
Jaliya
Sometimes we face this situation where we want to fill some values into some variables and we want to send those values to a web page where it will open in a new window. If you want to do all this in a single button click, there is something you should think about.
In javascript, there is window.open() method, which you can use to open the new window in any way you prefer. But since that would be a client side event, it will run before the server side events. Which means if you write all the session variable assigning part in your server side click event which is,
OnClickit will fire after executing client side click event which is, OnClientClickSo as a solution to that, this is the code snippet to open a new window from the code behind file under the server side click event. ClientScript.RegisterStartupScript(this.GetType(), "PopupWindow", "<script language='javascript'>window.open('YourPage.aspx','Title','width=600,height=300')</script>");Happy Coding.