Aug 07, 2013, 7:33 PM
[CLOSED] Resetting a Form on the client
Hi,
Please consider the code sample below. I'm curious what other call is required to select the initial value of a ComboBox on the server so that it doesn't get reset to empty on the client. I'm selecting an option on the server thinking that it's persisted into the form values. However, the Reset button cancels it out.
Please consider the code sample below. I'm curious what other call is required to select the initial value of a ComboBox on the server so that it doesn't get reset to empty on the client. I'm selecting an option on the server thinking that it's persisted into the form values. However, the Reset button cancels it out.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
var list = new List<object>
{
new {CountryName = "Canada", CountryID = 1},
new {CountryName = "Great Britain", CountryID = 2},
new {CountryName = "United States", CountryID = 3}
};
this.Store1.DataSource = list;
this.Store1.DataBind();
ComboBox1.SelectedItems.Clear();
ComboBox1.SelectedItems.Add(new Ext.Net.ListItem(2));
TextField1.Text = "Anything goes here";
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ext.Net 2.x</title>
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder2" runat="server" Mode="Style" />
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<ext:Viewport runat="server" Layout="FitLayout">
<Items>
<ext:FormPanel runat="server" ID="FormPanel1">
<Items>
<ext:ComboBox ID="ComboBox1" runat="server" DisplayField="CountryName" ValueField="CountryID"
TypeAhead="true" Editable="true" MinChars="2" SelectOnFocus="true" EmptyText="Select Country..."
FieldLabel="Select Country" QueryMode="Local">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="CountryID">
<Fields>
<ext:ModelField Name="CountryName" />
<ext:ModelField Name="CountryID" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
<ext:TextField runat="server" ID="TextField1" FieldLabel="Description">
</ext:TextField>
<ext:CheckboxGroup ID="CheckboxGroup1" runat="server" Width="300" FieldLabel="Some Options">
<Items>
<ext:Checkbox runat="server" BoxLabel="Option 1" InputValue="1" Checked="true">
</ext:Checkbox>
<ext:Checkbox runat="server" BoxLabel="Option 2" InputValue="2">
</ext:Checkbox>
</Items>
</ext:CheckboxGroup>
</Items>
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Reset Form" Icon="Cancel">
<Listeners>
<Click Handler="App.FormPanel1.reset();">
</Click>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:FormPanel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
Last edited by Daniil; Aug 08, 2013 at 2:25 PM.
Reason: [CLOSED]