Date Comparision Javascript Validation

function ValidateDate() { var str1 = document.getElementById(“”).value; var str2 = document.getElementById(“”).value; var dt1 = parseInt(str1.substring(0,2),10); var mon1 = parseInt(str1.substring(3,5),10); var yr1 = parseInt(str1.substring(6,10),10); var dt2 = parseInt(str2.substring(0,2),10); var mon2 = parseInt(str2.substring(3,5),10); var yr2 = parseInt(str2.substring(6,10),10); var date1 = new Date(yr1, mon1, dt1); var date2 = new Date(yr2, mon2, dt2); if(date2 < date1) { alert("To date …

Find Master Page Control In Content Page

Home News If I have understood this correctly… If your list is on the master page… Home News …then you can do this on your content page… Control list = this.Page.Master.FindControl(“list”); Then the li objects will be controls in the list object – e.g. list.Controls. Or you can do… Control home = this.Page.Master.FindControl(“list”).FindControl(“home”); …to find …

Javascript Validation in Gridview

Make function in “Java Script” as Below… grvPowderCoat is Gridview ID function PowderCoatValidate() { var result=””; var GrvTst = document.getElementById(GetClientId(“grvPowderCoat”)); if (GrvTst != null) { var Inputs = GrvTst.getElementsByTagName(“input”); for (i = 0; i < Inputs.length; i++) { if (Inputs[i].type == 'text') { var test1 = Inputs[i].id; var array1 = test1.split("_"); if (array1[array1.length-1] == 'txtPowderA') …

Enalbe Or Disable Controls In Asp.Net

Give ID and runat=”server” attribute to Div or Table Tag for enable or disable the controls in it. Write the followin function and call them on any event. Disable Controls private void DisableControls(Control parent) { foreach (Control _ChildControl in parent.Controls) { if ((_ChildControl.Controls.Count > 0)) { DisableControls(_ChildControl); } else { if (_ChildControl is TextBox) { …

Display Confirmation Message on Gridview Deleting

Write Javascript into head tag……… <head runat=”server”>     <title>GridView Data Manipulation</title>     <script type=”text/javascript” language=”javascript”>         function ConfirmOnDelete(item)         {           if (confirm(“Are you sure to delete: ” + item + “?”)==true)             return true;           else             return false;         }     </script> </head> Aspx page: Gridview <Columns>     <asp:BoundField DataField=”CustomerID” HeaderText=”ID” ReadOnly=”true” /> …

Popup in gridview

Create a button in Gridiview set command name and command argument. protected void grvViewInquiry_RowCommand( object sender, GridViewCommandEventArgs e) { if (e.CommandName == “Detail”) { int AppealId = Convert.ToInt32(e.CommandArgument.ToString()); string script = “window.open(‘ViewInquiryDetails.aspx?InqID=” + AppealId + “‘, ”,’width=800, height=500,top=130,left=90,resizable=yes’);”; ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), “Print”, script, true); } else if (e.CommandName == “Drawing”) { Response.Redirect(“ViewDrawings.aspx?InqID=” + Convert.ToString(e.CommandArgument)); } }

Generate Storeprocedure Dynamically

SqlConnection conn; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { } } protected void btnConnect_Click(object sender, EventArgs e) { if (txtUserID.Text == “” && txtPassword.Text == “”) { conn = new SqlConnection(); string strConn = “Data Source=” + txtSQLName.Text + “; Initial Catalog=” + txtDBName.Text + “; Integrated Security=True”; conn.ConnectionString = strConn; conn.Open(); …

Check IsIdentity true or false

Find SQL Table Cloumn name, data type,  column size select column_name, data_type, character_maximum_length char from information_schema.columns where table_name=’tblCountry’ Find IsIdentity true columns SELECT * from information_schema.columns where columnproperty(object_id(table_name),column_name, ‘IsIdentity’)=1 and table_name=’personal’ Find IsIdentity False Columns SELECT * from information_schema.columns where columnproperty(object_id(table_name),column_name, ‘IsIdentity’)=0 and table_name=’personal’

Find Database, Tables, Procedure Names in SQL Server

Find all database names in sql server select name from sys.databases Find all tables names in sql server for perticular database select Table_name from information_schema.tables Find all procedure names in sql server for perticular database select name from sys.procedures where object_definition(object_id) not like ‘%sp%’ SELECT name FROM sys.objects WHERE type = ‘P’

Send Email

You must have to use Gmail ID as From Email ID. USE: using System.Net.Mail; // Namespace OnSendMail Button Click Event : try { SmtpClient obj = new SmtpClient(“smtp.gmail.com”); obj.Credentials = new System.Net.NetworkCredential(“your@gmail.com”, “password”); obj.Port = 587; obj.Host = “smtp.gmail.com”; obj.EnableSsl = true; MailMessage message = new MailMessage(“your@gmail.com”,”to@yahoo.com”); message.Subject = txtSUB.Text; // subject textbox’s text message.Body …