Posts

Grid View Paging

  Grid View paging- Grid view paging is used when we have to read the data in bulk then we divide the complete data records into pages consists 10 records in one page. SqlDataAdapter - It is used for Grid View Paging Data Adapter reads data in group of 10 records unlike DataReader which reads the data line by line. DataSet - DataSet Object is created, it accepts the data in bulk. Fill() - Fill() is used. CODE - protected void display() { //Connection Code string s = ConfigurationManager.AppSettings["db"]; cn = new SqlConnection(s); cn.Open(); //DataSet Object DataSet ds = new DataSet(); string s = "select * from Videodb"; //SqlDataAdapter object SqlDataReader adp = new SqlDataAdapter(); adp.Fill(ds); GridView1.DataSoruce = ds; GridView1.DataBind(); } Source code-   <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"              Height="589px" Width="483px" OnPageIndexChanging="click...

UnEditable TextBox (For Security)

   <asp:TextBox ID="someId" runat="server" oncopy="return false" onpaste="return false" oncut="return false" ondelete="return false" Text="hi"></asp:TextBox> Note:- A textbox will be appeared in the screen on which you can not do any operation wheather  it is to copy the data , cut the data, paste the data and delete the data  - this is used for security purposes.

Sending Image Through Mail in dot net

Method 1: Sending mail by directly giving the link in src:- protected void mail_send(object sender, EventArgs e)     {         connectdb();         string q = "select img from wedding_regdb where userid='" + TextBox1.Text + "'";         cm = new SqlCommand(q, cn);         dr = cm.ExecuteReader();         if (dr.Read())         {                          GridViewRow gr1 = ((Button)sender).NamingContainer as GridViewRow;             Button b2 = (Button)gr1.FindControl("mailbtn");             SmtpClient sm = new SmtpClient("student-cell.com", 25);             sm.Credentials = new System.Net.NetworkCredential("contact@student-cell.com", "password");             sm.DeliveryMethod =...

API for whatsapp

        Response.Redirect("https://api.whatsapp.com/send?phone=+91" + TextBox1.Text + "&text=" + TextBox2.Text);

Final Project

Image
Registration form project   CODING- using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using System.Configuration; public partial class RegPage : System.Web.UI.Page {     SqlConnection cn;     SqlCommand cm;     SqlDataReader dr;     FinalClass fc = new FinalClass();     protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {             statedisplay();         }     }     protected void connect()     {         string s = ConfigurationManager.AppSettings["Ch_Db"];         cn = new SqlConnection(s);         cn.Open();          }     protected void statedisplay...

Checking File Extension

                   string ext = System.IO.Path.GetExtension(FileUpload1.FileName);         if (ext != ".jpg" && ext != ".jpeg")         {             Response.Write("accept only jpg file");         }         else         {              FileUpload1.SaveAs(Server.MapPath("~") + "//upload//" + FileUpload1.FileName);             Image1.ImageUrl = "~/upload/" +  FileUpload1.FileName;                 }

Export GridView to Excel

            string attachment = "attachment; filename=registration.xls";         Response.ClearContent();         Response.AddHeader("content-disposition", attachment);         Response.ContentType = "application/ms-excel";         StringWriter sw = new StringWriter();         HtmlTextWriter htw = new HtmlTextWriter(sw);         HttpContext.Current.Response.Write("<br>");         HtmlForm frm = new HtmlForm();         GridView1.Parent.Controls.Add(frm);         frm.Attributes["runat"] = "serve";         frm.Controls.Add(GridView1);         frm.RenderControl(htw);         Response.Write(sw.ToString());         Response.End();