简体   繁体   English

从aspx页面访问静态类方法

[英]Accessing static class method from aspx page

I get a "System.ArgumentException: Keyword not supported: '<%'." 我收到“ System.ArgumentException:不支持的关键字:'<%'。” error when I try to access a static class method that will determine what connectionstring I will be using. 当我尝试访问将确定要使用的连接字符串的静态类方法时发生错误。 It is probably a syntax error but I'm not very familiar with accessing class methods from an aspx page. 这可能是语法错误,但是我对从aspx页面访问类方法不是很熟悉。

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%=GetConnectionString.createConnectionString()%>" SelectCommand="SELECT * FROM [Activity]" OnSelecting="SqlDataSource1_Selecting1"></asp:SqlDataSource>

Single quotes for inline expressions: 内联表达式的单引号:

ConnectionString='<%=GetConnectionString.createConnectionString()%>'

Also have a look at this, which explains in which context(s) you can use the syntaxes <%# , <%= , and <%$ . 还要看一下,它说明了可以在哪种上下文中使用语法<%#<%=<%$

ASP.net Inline Expression Issue ASP.net内联表达式问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM