How to Get value from a text box when click on a button with button id " btnChng"
protected void btnChng_Click(object sender, EventArgs e) //Button Click Event
{
string content=txtName.Text; //save textbox value to string variable content
}
string : Type of data
content : Variable
txtName.Text: text value in the textbox( textbox id is "txtName")
***********************************************************************************
Enable/Disable TextBox
protected void btnEnable_Click(object sender, EventArgs e)
{
txtName.Enabled = true; // Enabled property set as true
}
protected void btnDisable_Click(object sender, EventArgs e)
{
txtName.Enabled = false;// Enabled property set as false
}
***********************************************************************************
TextBox Clear
protected void btnClear_Click(object sender, EventArgs e)
{
if (txtName.Text== "") //Check textbox is empty or not
{
Response.Write("<script>alert('There is no text entered...')</script>"); //Message
}
else
{
txtName.Text= "";//Clear textbox
}
}
**********************************************************************************************************
Check Type of data entered in Textbox
protected void btnTest_Click(object sender, EventArgs e)
{
Int32 result;
if (txtType.Text!= "") // Check textbox is empty or not
{
if (!int.TryParse(txtType.Text, out result)) // if any data in textbox ,Check it is int
type or not ...if it is not an integear then show below message
{
txtType.Text = "";
Response.Write("<script>alert('this field only contain numbers... ')</script>");
}
}
}
***********************************************************************************
Small Letter to Caps Convertion
There is two textbox
1.txtSmall
2.txtCaps
protected void btnConvert_Click(object sender, EventArgs e)
{
string small = txtSmall.Text;//save first box value
txtCaps.Text= small.ToUpper();//convert value use function("ToUpper()") and save in txtCaps
}
***********************************************************************************
Set Focus
protected void btnFL_Click(object sender, EventArgs e)
{
txtLeft.Focus();//focus() function used to focus a control
}
protected void btnFR_Click(object sender, EventArgs e)
{
txttxtRight.Focus();
}
protected void btnChng_Click(object sender, EventArgs e) //Button Click Event
{
string content=txtName.Text; //save textbox value to string variable content
}
string : Type of data
content : Variable
txtName.Text: text value in the textbox( textbox id is "txtName")
***********************************************************************************
Enable/Disable TextBox
protected void btnEnable_Click(object sender, EventArgs e)
{
txtName.Enabled = true; // Enabled property set as true
}
protected void btnDisable_Click(object sender, EventArgs e)
{
txtName.Enabled = false;// Enabled property set as false
}
***********************************************************************************
TextBox Clear
protected void btnClear_Click(object sender, EventArgs e)
{
if (txtName.Text== "") //Check textbox is empty or not
{
Response.Write("<script>alert('There is no text entered...')</script>"); //Message
}
else
{
txtName.Text= "";//Clear textbox
}
}
**********************************************************************************************************
Check Type of data entered in Textbox
protected void btnTest_Click(object sender, EventArgs e)
{
Int32 result;
if (txtType.Text!= "") // Check textbox is empty or not
{
if (!int.TryParse(txtType.Text, out result)) // if any data in textbox ,Check it is int
type or not ...if it is not an integear then show below message
{
txtType.Text = "";
Response.Write("<script>alert('this field only contain numbers... ')</script>");
}
}
}
***********************************************************************************
Small Letter to Caps Convertion
There is two textbox
1.txtSmall
2.txtCaps
protected void btnConvert_Click(object sender, EventArgs e)
{
string small = txtSmall.Text;//save first box value
txtCaps.Text= small.ToUpper();//convert value use function("ToUpper()") and save in txtCaps
}
***********************************************************************************
Set Focus
protected void btnFL_Click(object sender, EventArgs e)
{
txtLeft.Focus();//focus() function used to focus a control
}
protected void btnFR_Click(object sender, EventArgs e)
{
txttxtRight.Focus();
}
No comments:
Post a Comment