9/18/2014

Date and Time Format Strings in C#

Date and Time Format Strings in C#
Date and Time Format Strings in C#


private void dateTimePicker1_ValueChanged(object sender, EventArgs e)  
     {  
       label15.Text = dateTimePicker1.Value.ToString("d");  
       label16.Text = dateTimePicker1.Value.ToString("D");  
       label17.Text = dateTimePicker1.Value.ToString("f");  
       label18.Text = dateTimePicker1.Value.ToString("F");  
       label19.Text = dateTimePicker1.Value.ToString("g");  
       label20.Text = dateTimePicker1.Value.ToString("G");  
       label21.Text = dateTimePicker1.Value.ToString("m");  
       label22.Text = dateTimePicker1.Value.ToString("r");  
       label23.Text = dateTimePicker1.Value.ToString("s");  
       label24.Text = dateTimePicker1.Value.ToString("t");  
       label25.Text = dateTimePicker1.Value.ToString("T");  
       label26.Text = dateTimePicker1.Value.ToString("u");  
       label27.Text = dateTimePicker1.Value.ToString("U");  
       label28.Text = dateTimePicker1.Value.ToString("y");  
     }   

7/10/2014

Increment the value of Qty if row with the same data already exists in DataGridView

Increment the value of Qty if row with the same data already exists in DataGridView
Increment the value of Qty if row with the same data already exists in DataGridView


private void btn_Add_Click(object sender, EventArgs e)  
     {  
       //Boolean value to check if the DataGridView has the same value.  
       bool Found = false;  
       double total = Convert.ToDouble(txt_Price.Text) * 1;  
       if (dataGridView1.Rows.Count > 0)  
       {  
         //Check if the product Name exists with the same Price  
         foreach (DataGridViewRow row in dataGridView1.Rows)  
         {  
           if (Convert.ToString(row.Cells[0].Value) == txt_Name.Text && Convert.ToString(row.Cells[2].Value) == txt_Price.Text)  
           {  
             //Update the Quantity of the found row  
             row.Cells[1].Value = Convert.ToString(1 + Convert.ToInt16(row.Cells[1].Value));  
             row.Cells[3].Value = Convert.ToDouble(row.Cells[1].Value) * Convert.ToDouble(row.Cells[2].Value);  
             Found = true;  
           }  
         }  
         if (!Found)  
         {  
           //Add the row to DataGridView if data not present  
           dataGridView1.Rows.Add( txt_Name.Text,1, txt_Price.Text,total);  
         }  
       }  
       else  
       {  
         //Add the first row to DataGridView if there is no row  
         dataGridView1.Rows.Add( txt_Name.Text, 1, txt_Price.Text,total);  
       }  
     }  

3/12/2014

CSS3 background-size Property


 background-size: auto|length|cover|contain|initial|inherit;  
 #header  
 {  
   float: right;  
   width: 670px;  
   height: 200px;  
   background-image: url('  ');  
   background-position:center;   
   background-size:cover;  
   background-repeat: no-repeat;  
 }  

1/07/2014

C# Scrolling label's text to the left

Scrolling label's text to the left
Scrolling label's text to the left


private void timer1_Tick(object sender, EventArgs e)  
     {  
       lblScroll.Text = lblScroll.Text.Substring(1, lblScroll.Text.Length - 1) + lblScroll.Text.Substring(0, 1);  
     }  
 private void ScrollText_Load(object sender, EventArgs e)  
     {  
       lblScroll.Text = "   Text is moving   ";  
     }  

C# Moving Label to the left and right

Moveing Label to the left and right
Moving Label to the left and right


 public partial class ScrollText : Form  
   {  
     public bool moveright = true; //This Variable should be declared globaly  
     public ScrollText()  
     {  
       InitializeComponent();  
     }  
     private void timer1_Tick(object sender, EventArgs e)  
     {  
       if (moveright == true)  
       {  
         lblScroll.Left += 5;  
       }  
       else  
       {  
         lblScroll.Left -= 5;  
       }  
       if (lblScroll.Left <= Convert.ToInt32(this.ClientRectangle.Left))  
       {  
         moveright = true;  
       }  
       if (lblScroll.Left + lblScroll.Width >= Convert.ToInt32(this.ClientRectangle.Right))  
       {  
         moveright = false;  
       }  
     }  
   }  

C# Scroll label from left to right

Scroll label from left to right
Scroll label from left to right


private void timer1_Tick(object sender, EventArgs e)  
     {  
       if (lblScroll.Left >= Convert.ToInt32(this.ClientRectangle.Right))  
       {  
         lblScroll.Left = this.ClientRectangle.Left - lblScroll.Left;  
       }  
       else  
       {  
         lblScroll.Left += 4;  
       }  
     }  

C# Scrolling a label from right to left

Scroll label from right to left
Scroll label from right to left


private void timer1_Tick(object sender, EventArgs e)  
   {  
      if (lblScroll.Left + lblScroll.Width <= Convert.ToInt32(this.ClientRectangle.Left))  
       {  
         lblScroll.Left = this.ClientRectangle.Right;  
       }  
      else  
       {  
         lblScroll.Left -= 4;  
       }  
   }  

1/03/2014

Asp .Net Error 'The resource cannot be found'

Asp .Net Error 'The resource cannot be found'
Asp .Net Error 'The resource cannot be found'

<configuration>

    <system.web>
      <compilation debug="true" targetFramework="4.5.1" />
      <httpRuntime targetFramework="4.5.1" />
    
  <customErrors mode="On" defaultRedirect="~/Errors/GeneralErrors.aspx">
    <error statusCode="403" redirect="~/Errors/Error403.aspx"/>
    <error statusCode="404" redirect="~/Errors/Error404.aspx"/>
    <error statusCode="500" redirect="~/Errors/Error500.aspx"/>
  </customErrors>
    
    </system.web>

</configuration>

1/02/2014

Asp .Net WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery' Error

Asp .Net WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery' Error
Asp .Net WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery' Error


<configuration>  
  <system.web>  
   <compilation debug="true" targetFramework="4.5.1" />  
   <httpRuntime targetFramework="4.5.1" />  
  </system.web>  
  <appSettings>  
   <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />  
  </appSettings>  
 </configuration>