Thursday, June 20, 2013

How to get all text in uppercase latters in a textbox using java script in asp.net

use this script in header section :-
--------------------------------

<script type="text/javascript">
        function ToUpper(txt) {
            document.getElementById(txt).value = document.getElementById(txt).value.toUpperCase();
        }
</script>



Take a textbox like this and call the java script function over here. :-
-------------------------------------------------------------------

<asp:TextBox ID="txtCode" runat="server" AutoPostBack="True"
                             ontextchanged="txtCode_TextChanged" MaxLength="99"  onkeypress="ToUpper(this.id)" onblur="ToUpper(this.id)"></asp:TextBox>

Friday, May 17, 2013

How to passing the value from One form to another form in windows application c#

 Write code on Form -1 :--
=======================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 objForm2 = new Form2(this);
            objForm2.Show();

        }

      public void PassValue(string strValue)
    {
        textBox1.Text = strValue;
    }


    }
}
------------------------------------------------------------------------------------------------------------


Write code on form : 2:-
=====================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        Form1 ownerForm = null;
        public Form2()
        {
            InitializeComponent();
        }
        public Form2(Form1 ownerForm)            //create parameterized  constructor for form 1
        {
            InitializeComponent();
            this.ownerForm = ownerForm;
        }
        private void Form2_Load(object sender, EventArgs e)
        {
        
        }

      

        private void button1_Click(object sender, EventArgs e)
        {
            this.ownerForm.PassValue(textBox1.Text);
            this.Close();
        }
    }
}