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(); …

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 …

File Extension Javascript Validation

<script language=”javascript” type=”text/javascript”> function chkFile() { var fextension = document.getElementById(“<%=FileUpload1.ClientID %>”).value; var exten = fextension.split(“.”); var len=exten.length; //alert(exten.length); if(exten[len-1]==”doc” || exten[len-1]==”docx”) { alert(“File upload successfully”); return true; } else { alert(“Please select doc file”); return false; } } </script>

Create Folder/Directory Check Existing

Create Folder/Directory and Check Existing or not Here Session[“user”] is a name which will be created…. ‘upload’ is a floder/Director that already created. if(Directory.Exists(Server.MapPath(“upload”) + “/” + Session[“user”].ToString())) { } else { System.IO.Directory.CreateDirectory(Server.MapPath(“upload”) + “/” + Session[“user”].ToString()); }

DataTable : (Use For Make Shopping Cart)

First Time Page Load Gridview Shown as below .aspx Page Coding <div> <asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False” ShowFooter=”True” > <Columns> <asp:TemplateField HeaderText=”Rollno”> <ItemTemplate> <asp:Label ID=”lblRno” runat=”Server” Text=””></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText=”Name”> <ItemTemplate> <asp:Label ID=”lblName” runat=”server” Text='<%# Eval(“name”) %>’></asp:Label> </ItemTemplate> <FooterTemplate> <asp:TextBox ID=”txtName” runat=”server” Text=””></asp:TextBox> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText=”City”> <ItemTemplate> <asp:Label ID=”lblCity” runat=”server” Text='<%# Eval(“city”) %>’></asp:Label> </ItemTemplate> …

Checkbox Gridview Javascript Multiple Delete Records

–JavaScript– <script language=”javascript” type=”text/javascript”> //user for select all checkbox function SelectAllCheckboxes(spanChk){ // Added as ASPX uses SPAN for checkbox var oItem = spanChk.children; var theBox= (spanChk.type==”checkbox”) ? spanChk : spanChk.children.item[0]; xState=theBox.checked; elm=theBox.form.elements; for(i=0;i<elm.length;i++) if(elm[i].type==”checkbox” && elm[i].id!=theBox.id) { //elm[i].click(); if(elm[i].checked!=xState) elm[i].click(); //elm[i].checked=xState; } } //User for check any checkbox is selected or not and delete confirm …

Java Script Validation onSubmit event of form

<script language=”javascript” type=”text/javascript”> function validateFormOnSubmit(theForm) { var reason = “”; var intFlag = 0; //Radio button List validation reason += validateTextBox(); reason += validateLastName(); reason += validateDate(); reason += validateQualification(); reason += validateRadioButtonList(); if(reason != “”) { //alert(“Please select Student Status”); alert(reason); return false; } else { return true; } /* complete radio list validation …

2 list box item transfer together

Add Item into ListBox Write below code in page load event for adding items in listbox1 if (!Page.IsPostBack) { ListBox1.Items.Add(“Baroda”); ListBox1.Items.Add(“Anand”); ListBox1.Items.Add(“Ahmedabad”); ListBox1.Items.Add(“Pune”); } Now create another list box and one button to transfer multiple selected item from previous listbox Write downbelow code in Button Click event……….. int sel = 0; for (int i = …