Skip to main content

Posts

Showing posts from March, 2012

Clear text in All Text Box Controls

Clear text in All Text Box Controls Reset the all text box Control by using Following Function Usage : Resetfromcontrol(this); Function : public void Resetfromcontrol(Control parent)     {         try         {             foreach (Control c in parent.Controls)             {                 if (c.Controls.Count > 0)                 {                     Resetfromcontrol(c);                 }                 else                 {                     switch (c.GetType().ToString())                     {                         case "System.Web.UI.WebControls.TextBox":                             ((TextBox)c).Text = "";                             break;                     }                 }             }         }         catch         {         }     }

Look Up Page Data Bound

Create Look up Page Data Bound //Opener Page (Look Up page) Step 1 : Add following script in Lookup.aspx page // Lookup.aspx < script language ="javascript" type ="text/javascript">        function GetRowValue(val)     {        if (val != '&nbsp;' )     {        val1 = 0;     window.opener.document.getElementById( 'ctl00_ContentPlaceHolder1_hdfID' ).value = val;     window.opener.document.getElementById( 'ctl00_ContentPlaceHolder1_hdfFlagID' ).value = val1;     }     window.opener.document.forms[0].submit();     self.close();        }        </ script > // in code behinds lookup.aspx.cs Step2 : InGridView- Go to edit item template in grid and select the button field and convert as item template field and command name as ‘select’ Step3 :   Add below code protected void grdDetails_RowDataBound( object sender, GridViewRowEventArgs e)     {         if ((e.Row.RowType

create sorting for a Grid View

Code to create Sorting for a GridView in ASP.net in Code Behind? Step 1: Add the Property in your Class   public string SortField {             get {                 return ( string ) ViewState [ "_sortField" ];             }             set {                 ViewState [ "_sortField" ] = value ;             }         }         public string SortDir {             get {                 return ( string ) ViewState [ "_sortDir" ];             }             set {                 ViewState [ "_sortDir" ] = value ;             }         }   setp 2 : Enable the Gridview Sorting using the Events     protected void GridView1_Sorting ( object sender , GridViewSortEventArgs e ) {             if ( e . SortExpression == SortField && SortDir != "desc" ) {                 SortDir = "desc" ;             }             else {                 SortDir = "asc"

Java Script Validation for Text Boxes

Java Script Validation for Text Boxes     function NumberhyphenOnly()         {            var AsciiValue=event.keyCode             if((AsciiValue>=48 && AsciiValue<=57) || (AsciiValue==8 || AsciiValue==127) || (AsciiValue==45) || (AsciiValue==47))                 event.returnValue=true;             else             {                 event.returnValue=false;                                 alert("Enter NumericValues, '/', '-' Only");                }         }                 function NumberCharandHypehn()         {          var AsciiValue=event.keyCode             if((AsciiValue>=48 && AsciiValue<=57) || (AsciiValue>=65 && AsciiValue<=90) || (AsciiValue>=97 && AsciiValue<=122 ) || (AsciiValue==8 || AsciiValue==127) || (AsciiValue==45) || (AsciiValue==47) || (AsciiValue==46) || (AsciiValue==32))                 event.returnValue=true;             else             {                 event.returnValue=fa

Binding the image Control with bytes

Binding the image Control with byte  File upload control on client side show image using byte array //File upload control on change to post the method fileupload control  and image control should be in update panel <asp:FileUpload ID="FileUpload1" runat="server"  onchange="this.form.submit();" /> image control on page // on page load   if (FileUpload1.PostedFile != null && FileUpload1.PostedFile. ContentLength > 0)         {             UploadImage();                  } // upload image method  void UploadImage()     {         //Session["File"] = fluPicture.FileBytes;         //Session["Name"] = fluPicture.FileName;         // string scanletterFileName = "";         string  letterUploadFileName = System.IO.Path.GetFileName( FileUpload1 .PostedFile.FileName);         try         {             string[] fileType = FileUpload1 .PostedFile.FileName.Split('.' );