asp.net 控件 (.ascx) 与 dijit?

发布于 2024-08-17 08:42:55 字数 1855 浏览 4 评论 0原文

我试图让一个 asp.net 下拉列表控件成为一个 dijit 组合框,但它不起作用。

我已经尝试过:

<asp:DropDownList ID="ddlUserID" dojoType="dijit.form.ComboBox" runat="server" 
    DataTextField="FullNameAndUserName"
    CssClass="stdtext" DataValueField="UserID" AppendDataBoundItems="True" 
    AutoPostBack="True"
    meta:resourcekey="ddlUserIDResource1" EnableTheming="False">
    <asp:ListItem Text="(All Users)" Value="0" meta:resourcekey="ListItemResource1" />
</asp:DropDownList> 
   <script type="text/javascript" src="../scripts/dojo/dojo.js"></script> 
   <script type="text/javascript">
    dojo.require('dijit.form.ComboBox');
</script>

dojo.js 的路径是相对于 ascx 控件的包含父页面的,并且根据 firebug 可以正常加载。

渲染的html是这样的:

   <select id="invoiceReport1_ddlUserID" class="stdtext" dojotype="dijit.form.ComboBox" onchange="javascript:setTimeout('__doPostBack(\'invoiceReport1$ddlUserID\',\'\')', 0)" name="invoiceReport1$ddlUserID">
   </select>
   <script src="../scripts/dojo/dojo.js" type="text/javascript">
   </script>
   <script type="text/javascript">
   </script>
   <script type="text/javascript">

查看 http://docs.dojocampus.org/dijit 中的示例/表单/组合框 我不明白为什么生成的选择标签不是组合框。

我也尝试过这个:

HtmlGenericControl ctrl1 = new HtmlGenericControl("Script");
ctrl1.Attributes.Add("Type", "Text/Javascript");
ctrl1.Attributes.Add("src", "../Scripts/dojo/dojo.js");
this.Page.Header.Controls.Add(ctrl1);


HtmlGenericControl ctrl2 = new HtmlGenericControl("Script");
ctrl2.Attributes.Add("Type", "Text/Javascript");
ctrl2.InnerText = "dojo.require('dijit.form.ComboBox');";
this.Page.Header.Controls.Add(ctrl2);

有什么建议吗?

i've tried to get an asp.net dropdownlist control to become a dijit combobox but it's not working.

i've tried this:

<asp:DropDownList ID="ddlUserID" dojoType="dijit.form.ComboBox" runat="server" 
    DataTextField="FullNameAndUserName"
    CssClass="stdtext" DataValueField="UserID" AppendDataBoundItems="True" 
    AutoPostBack="True"
    meta:resourcekey="ddlUserIDResource1" EnableTheming="False">
    <asp:ListItem Text="(All Users)" Value="0" meta:resourcekey="ListItemResource1" />
</asp:DropDownList> 
   <script type="text/javascript" src="../scripts/dojo/dojo.js"></script> 
   <script type="text/javascript">
    dojo.require('dijit.form.ComboBox');
</script>

the path to dojo.js is relative to the containing parent page of the ascx control and loads fine according to firebug.

the rendered html is this:

   <select id="invoiceReport1_ddlUserID" class="stdtext" dojotype="dijit.form.ComboBox" onchange="javascript:setTimeout('__doPostBack(\'invoiceReport1$ddlUserID\',\'\')', 0)" name="invoiceReport1$ddlUserID">
   </select>
   <script src="../scripts/dojo/dojo.js" type="text/javascript">
   </script>
   <script type="text/javascript">
   </script>
   <script type="text/javascript">

looking at the examples from http://docs.dojocampus.org/dijit/form/ComboBox
i cant see why the resulting select tag is not a combobox.

i've also tried this:

HtmlGenericControl ctrl1 = new HtmlGenericControl("Script");
ctrl1.Attributes.Add("Type", "Text/Javascript");
ctrl1.Attributes.Add("src", "../Scripts/dojo/dojo.js");
this.Page.Header.Controls.Add(ctrl1);


HtmlGenericControl ctrl2 = new HtmlGenericControl("Script");
ctrl2.Attributes.Add("Type", "Text/Javascript");
ctrl2.InnerText = "dojo.require('dijit.form.ComboBox');";
this.Page.Header.Controls.Add(ctrl2);

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦旅人picnic 2024-08-24 08:42:55

解决方案最终是这样的:

您必须在样式表中或直接引用 dijit.css。

the solution ended up being this:

you must refer to dijit.css either in your stylesheet or directly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文