Dec 14, 2008, 3:28 PM
Creating a Store From CodeBehind
Creating a Store From CodeBehind
Javascript error --> Store1 undefined
Where is the code problem ??
<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeFile="ComboBoxDynamicStoreBind.aspx.cs"
Inherits="ComboBoxDynamicStoreBind" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" SourceFormatting="True" />
<ext:ComboBox ID="ComboBox1" runat="server" Mode="Local" Editable="false" ForceSelection="true"
TypeAhead="true" Selectonfocus="true" DisplayField="CustomerName" ValueField="CustomerId"
EmptyText="Lütfen Seçiniz.." StoreID="Store1">
</ext:ComboBox>
</form>
</body>
</html>
//Code Behind - Page Load
protected void Page_Load(object sender, EventArgs e)
{
RecordField customerId = new RecordField("CustomerId");
customerId.Mapping = "CustomerId";
customerId.Type = RecordFieldType.Int;
RecordField customerName = new RecordField("CustomerName");
customerName.Mapping = "CustomerName";
customerName.Type = RecordFieldType.String;
ArrayReader arrayReader = new ArrayReader();
arrayReader.ReaderID = "arrayReaderTest";
arrayReader.Fields.Add(customerId);
arrayReader.Fields.Add(customerName);
Store store = new Store();
store.ID = "Store1";
this.form1.Controls.Add(store);
store.Reader.Add(arrayReader);
store.DataSource = new Customers().GetCustomersList(10);
store.DataBind();
}
<!--Page Render HTML Code-->
<!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>
<!-- Coolite Toolkit for ASP.NET [Professional Edition]. Version 0.6.0.7019. -->
<link rel="stylesheet" type="text/css" href="/CooliteDemo/extjs/resources/css/ext-all-embedded-css/coolite.axd" />
<title>
Untitled Page
</title>
<script type="text/javascript" src="/CooliteDemo/extjs/adapter/ext/ext-base-js/coolite.axd?7019"></script>
<script type="text/javascript" src="/CooliteDemo/extjs/ext-all-debug-js/coolite.axd?7019"></script>
<script type="text/javascript" src="/CooliteDemo/coolite/coolite-core-js/coolite.axd?7019"></script>
<script type="text/javascript" src="/CooliteDemo/coolite/coolite-data-js/coolite.axd?7019"></script>
<script type="text/javascript">
//<![CDATA[
Ext.onReady(function(){Ext.QuickTips.init();Coolite.Ext.ScriptManagerUniqueID='ScriptManager1';Coolite.Ext.ThisUrl='http://localhost:1471/CooliteDemo/ComboBoxDynamicStoreBind.aspx';this.Store1_Data=[{"CustomerId":1,"CustomerName":"Customer Name 0"},{"CustomerId":2,"CustomerName":"Customer Name 1"},{"CustomerId":3,"CustomerName":"Customer Name 2"},{"CustomerId":4,"CustomerName":"Customer Name 3"},{"CustomerId":5,"CustomerName":"Customer Name 4"},{"CustomerId":6,"CustomerName":"Customer Name 5"},{"CustomerId":7,"CustomerName":"Customer Name 6"},{"CustomerId":8,"CustomerName":"Customer Name 7"},{"CustomerId":9,"CustomerName":"Customer Name 8"},{"CustomerId":10,"CustomerName":"Customer Name 9"}];this.Store1=new Coolite.Ext.Store({
id: "Store1",
ajaxPostBackConfig: {
formProxyArg: "form1"
},
reader: new Ext.data.ArrayReader({
fields: [{
type: "int",
mapping: "CustomerId",
name: "CustomerId"
},{
type: "string",
mapping: "CustomerName",
name: "CustomerName"
}]
}),
autoLoad: true,
serverID: "Store1"
});this.Store1.proxy=new Ext.data.PagingMemoryProxy(Store1_Data, false);this.ComboBox1=new Ext.form.ComboBox({
id: "ComboBox1",
renderTo: "ComboBox1_Container",
selectOnFocus: true,
emptyText: "Lütfen Seçiniz..",
store: Store1,
valueField: "CustomerId",
typeAhead: true,
queryDelay: 10,
mode: "local",
hiddenName: "ComboBox1_Value",
forceSelection: true,
editable: false,
displayField: "CustomerName",
listeners: {
render: {
fn: function(el){el.getEl().dom.setAttribute("name","ComboBox1");}
}
},
serverID: "ComboBox1"
});});Ext.BLANK_IMAGE_URL="/CooliteDemo/extjs/resources/images/default/s-gif/coolite.axd";
//]]>
</script>
</head>
<body>
<form name="form1" method="post" action="ComboBoxDynamicStoreBind.aspx" id="form1">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2Mjk4NDI4MDAPZBYCAgMPZBYEAgEPZBYCZg8UKhJTeXN0ZW0uV2ViLlVJLlBhaXIBDwUJdnNNZW1iZXJzFCsAAQ8FBlJlYWRlchQrBAEPBQRiYXNlFgIeCFJlYWRlcklEBQ9hcnJheVJlYWRlclRlc3RkAgMPFCsEAQ8FCXZzTWVtYmVycxQrAAEPBQlMaXN0ZW5lcnMUKwABDwUGUmVuZGVyFCsEAQ8FBGJhc2UWAh4HSGFuZGxlcgUwZWwuZ2V0RWwoKS5kb20uc2V0QXR0cmlidXRlKCJuYW1lIiwiQ29tYm9Cb3gxIik7ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAgUOU2NyaXB0TWFuYWdlcjEFCUNvbWJvQm94MVaWes/UOgP8uGKmRRi/8d2tulnl" />
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
</script>
<div id="ComboBox1_Container" style="display:inline;">
</form>
</body>
</html>