You can get and set value for WebInput from code behind.
In this topic, you will learn how to set different initial value WebInput.
To set simple input initial value
- Drag WebInput instance to WebForm.
- In Page_Load event handler function, put the following
code:
-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
wiSimpleInput.Value="simple alphanumeric text for webinput 1234567890";
}
}
|
To set DateTimeFree input initial value
- Drag WebInput instance to WebForm.
- In Page_Load event handler function, put the following
code:
-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
wiDateTimeFreeInput.Value = new DateTime(2007, 1, 1);
}
}
|
To set DateTimeMasked input initial value
- Drag WebInput instance to WebForm.
- In Page_Load event handler function, put the following
code:
-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
wiDateTimeMaskedInput.Value = new DateTime(2007, 1, 31);
}
}
|
To set Number input initial value
- Drag WebInput instance to WebForm.
- In Page_Load event handler function, put the following
code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
wiNumberInput.Value = 12345;
}
}
|
To set DynamicCurrency input initial value
- Drag WebInput instance to WebForm.
- In Page_Load event handler function, put the following
code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
decimal currencyValue = 1000000000000000000000m;
wiDynamicCurrencyInput.Value = currencyValue;
}
}
|
To get value from server-side
- Drag WebInput, ASP.NET button and label instance to WebForm.
- In Button_Click event, put the following code:
protected void Button1_Click(object sender, EventArgs e)
{
lblSimpleInput.Text = "postback value : " + wiSimpleInput.Text;
}
|