从aspx页面访问静态类方法 [英] Accessing static class method from aspx page

查看:67
本文介绍了从aspx页面访问静态类方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个System.ArgumentException:关键字不支持:'<%'。当我尝试错误访问静态类的方法,这将决定我将使用什么样的ConnectionString。这可能是一个语法错误,但我不是很熟悉,从aspx页面访问类的方法。

 < ASP:SqlDataSource的ID =SqlDataSource1=服务器的ConnectionString =<%= GetConnectionString.createConnectionString()%GT;的SelectCommand =SELECT * FROM [活动]OnSelecting =SqlDataSource1_Selecting1>< / ASP:SqlDataSource的>


解决方案

有关内嵌前pressions单引号:

 的ConnectionString ='<%= GetConnectionString.createConnectionString()%GT;'


也可以看看这个,这也解释了其中的上下文(S),你可以使用语法<%#<% = <%$

ASP.net在线防爆pression问题

I get a "System.ArgumentException: Keyword not supported: '<%'." 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.

<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

这篇关于从aspx页面访问静态类方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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