解决方法无法修改Controls集合,因为控件包含代码块(即<%...%>) [英] How Solved The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

查看:89
本文介绍了解决方法无法修改Controls集合,因为控件包含代码块(即<%...%>)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Dear All,
This Md Syedur Rahman. I am trying implement autocomplete without using ajax in Asp.Net. Given code below:

frmCrmOffer.aspx file:
<head>
<script type="text/javascript">
$(document).ready(function () {

var item = '<%=this.data%>';
var lists = new Array();
lists = item.split(',');
$("#txtauto").autocomplete({
source:lists
});
});
</script>
</head>

.cs file

protected void Page_Load(object sender, EventArgs e)
{


FillData();
}


public void FillData()
{
DataTable dt = new DataTable();
SqlCon = db.GetDBConn();
MySqlCommand sqlcmd = new MySqlCommand();
SqlCon.Open();
MySqlDataAdapter da = new MySqlDataAdapter("select name from mbi_customers where type='Dealer' and status=1 order by name", SqlCon);
da.Fill(dt);
SqlCon.Close();

if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)

{

data += (Convert.ToString(dt.Rows[i]["Name"])) + ",";

}

}

}







when I run application generate this Error

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

How can Solved this Problem.


Md Syedur Rahman
syed.syed04@gmail.com

推荐答案

(document).ready(function(){

var item ='<% = 这个 .data %> ';
var lists = new Array();
lists = item.split(', ');
(document).ready(function () { var item = '<%=this.data%>'; var lists = new Array(); lists = item.split(',');


(#txtauto)。autocomplete({
source:lists
});
});
< / script >
< / head >

.cs file

protected void Page_Load(object sender,EventArgs e)
{


FillData();
}


public void FillData()
{
DataTable dt = new DataTable();
SqlCon = db.GetDBConn();
MySqlCommand sqlcmd = new MySqlCommand();
SqlCon.Open();
MySqlDataAdapter da = new MySqlDataAdapter(从mbi_customers中选择名称,其中type ='Dealer',status = 1 order by name,SqlCon);
da.Fill(dt);
SqlCon.Close();

if(dt.Rows.Count> 0)
{
for(int i = 0; i < dt.Rows.Count; i ++)

{

数据 + = (Convert.ToString(dt.Rows [i] [ 名称])) + ,;

}

}

}







I 运行 application 生成 错误

控件 集合 不能 be 已修改 因为 control 包含 < span class =code-attribute>
cod e blocks (即 <% ... > )。

如何解决这个问题。


Md Syedur Ra​​hman
syed.syed04@gmail.com
("#txtauto").autocomplete({ source:lists }); }); </script> </head> .cs file protected void Page_Load(object sender, EventArgs e) { FillData(); } public void FillData() { DataTable dt = new DataTable(); SqlCon = db.GetDBConn(); MySqlCommand sqlcmd = new MySqlCommand(); SqlCon.Open(); MySqlDataAdapter da = new MySqlDataAdapter("select name from mbi_customers where type='Dealer' and status=1 order by name", SqlCon); da.Fill(dt); SqlCon.Close(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { data += (Convert.ToString(dt.Rows[i]["Name"])) + ","; } } } when I run application generate this Error The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>). How can Solved this Problem. Md Syedur Rahman syed.syed04@gmail.com


这篇关于解决方法无法修改Controls集合,因为控件包含代码块(即&lt;%...%&gt;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆