从.ascx调用.cs方法/函数 [英] Call .cs method/function from .ascx

查看:104
本文介绍了从.ascx调用.cs方法/函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有没有办法从runat = server标签的属性

调用代码隐藏方法/函数,有点像这样:


< asp:Literal runat =" server" ID = QUOT; litTest" Text =''<%#

MyMethod(" testargs")%>''/>


但显然不是工作:(


谢谢


Andrew

解决方案

< tr ****** @ googlemail.com写信息

新闻:11 ******************** **@r34g2000hsd.googlegr oups.com ...


有没有办法从属性中调用代码隐藏方法/函数

一个runat =服务器标签,有点像这样:


< asp:Literal runat =" server" ID =" litTest" Text =''<%#

MyMethod(" testargs")%>''/>


但显然不起作用:(


1)确保MyMethod返回一个字符串


2)确保MyMethod具有受保护或公共范围


3)将<%#更改为<%=

-

Mark Rae

ASP.NET M副总裁
http://www.markrae.net


tr******@googlemail.com 写道:





有没有办法从属性调用代码隐藏方法/函数

的runat =服务器标签,有点像这样:


< asp:Literal runat =" server" ID = QUOT; litTest" Text =''<%#

MyMethod(" testargs")%>''/>


但显然不是工作:(


谢谢


安德鲁



我更喜欢把代码背后的代码:


litTest.Text = MyMethod(" testargs");


-

G?ran Andersson

_____
http:// www .guffa.com


8月1日,13:13,Mark Rae [MVP]< m ... @ markNOSPAMrae.netwrote :


< trull ... @ googlemail.comwrote in message


news:11 ****** ****************@r34g2000hsd.googlegr oups.com ...


有没有办法调用代码隐藏方法/函数来自属性

的runat = server标签,有点像这样:


< asp:Literal runat =" server" ID = QUOT; litTest" Text =''<%#

MyMethod(" testargs")%>''/>


但显然不起作用:(



1)确保MyMethod返回一个字符串


2)确保MyMethod具有受保护或公共范围


3)将<%#更改为<% = b / b

Mark Rae

ASP.NET MVPhttp://www.markrae.net






我试过了,但它只是字面上写出:<%=

MyMethod(" ; testargs")%生成的html。


:(


Goran,我不能这样做是因为一个复杂的原因,我不会混淆关于

关于这里。我只需要能够从html中执行,而不是

代码隐藏。


任意其他任何想法?


谢谢


Hi,

Is there a way to call a codebehind method/function from an attribute
of a runat=server tag, kinda like this:

<asp:Literal runat="server" ID="litTest" Text=''<%#
MyMethod("testargs") %>'' />

but obviously that doesn''t work :(

Thanks

Andrew

解决方案

<tr******@googlemail.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...

Is there a way to call a codebehind method/function from an attribute
of a runat=server tag, kinda like this:

<asp:Literal runat="server" ID="litTest" Text=''<%#
MyMethod("testargs") %>'' />

but obviously that doesn''t work :(

1) Make sure MyMethod returns a string

2) Make sure MyMethod has either protected or public scope

3) Change <%# to <%=
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


tr******@googlemail.com wrote:

Hi,

Is there a way to call a codebehind method/function from an attribute
of a runat=server tag, kinda like this:

<asp:Literal runat="server" ID="litTest" Text=''<%#
MyMethod("testargs") %>'' />

but obviously that doesn''t work :(

Thanks

Andrew

I prefer to put the code in the code behind:

litTest.Text = MyMethod("testargs");

--
G?ran Andersson
_____
http://www.guffa.com


On 1 Aug, 13:13, "Mark Rae [MVP]" <m...@markNOSPAMrae.netwrote:

<trull...@googlemail.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...

Is there a way to call a codebehind method/function from an attribute
of a runat=server tag, kinda like this:

<asp:Literal runat="server" ID="litTest" Text=''<%#
MyMethod("testargs") %>'' />

but obviously that doesn''t work :(


1) Make sure MyMethod returns a string

2) Make sure MyMethod has either protected or public scope

3) Change <%# to <%=

--
Mark Rae
ASP.NET MVPhttp://www.markrae.net

Hi,

I tried that but it just literally writes out: <%=
MyMethod("testargs") %into the resultant html.

:(

Goran, I cant do that for a complicated reason that i wont rabble on
about here. I just need to be able to do it from the html, not the
codebehind.

Any other ideas anyone?

Thanks


这篇关于从.ascx调用.cs方法/函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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