asp.net在线code<%#MyboolVal%GT; [英] asp.net inline code <%# MyboolVal %>

查看:77
本文介绍了asp.net在线code<%#MyboolVal%GT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在这里失去了一些东西愚蠢的,但我无法看到它。我的工作使用内联code在其网站上,例如:

 <面板=服务器ID =身份识别码可见='<%#MyboolVal%GT;'>
    一些东西
< /面板>

这似乎工作非常适合他们,当他们的条件是满足的面板将显示。

我想在家里使用类似的方法在我的网站(较晚星期五晚上这样问我的老板是不是在这一点上最好的想法)。我根本无法得到它的输出任何东西。我已经尝试过在可见光领域,没有工作,所以我想我只是把它写的东西到屏幕上:

 < P>有的文字<%#的String.Format(meeee {0},Mybool)%GT;< / P>

但我没有得到从内联code任何输出。在一些文本出现,但没有meeee或布尔值。

我是一个用户控件内这样做,在这一刻,但不要以为会是原因。

任何想法吗?

感谢

编辑...

确定这样的感谢弗雷迪·里奥斯的答复,我可以得到文本出现,但是当我尝试在:

 可见='<%= mybool%GT;'

我得到的编译错误:

无法从它的字符串重新presentation的Visible属性创建类型System.boolean的对象。

我很困惑,究竟发生了什么。必须有机罩我没有得到下的过程的一部分。

编辑2:

我得到行123错误:

 <字段集类=MyClass的ID =projectarea=服务器可见='<%= ShowProjectSearchArea%GT;'>

ShowProjectSearchArea是我的bool值,设置为false。

如果我双击错误列表窗口,我得到一个弹出,这是我从来没有见过以下错误:

 无法打开文件%1。它可能不是在溶液中。


解决方案

试着在你的版本使用=代替#:

 < P>有的文字<%=的String.Format(meeee {0},Mybool)%GT;< / P>

#是数据绑定,所以在原来的code,必须有数据绑定一个电话的地方。

I must be missing something stupid here but I can not see it. My work uses inline code on their sites, for example:

<panel runat="server" id="myid" visible='<%# MyboolVal %>'>
    some stuff
</panel>

That seems to work great for them, the panel will display when their condition is meet.

I am trying to use a similar approach on a site of mine at home (its late friday evening so asking my boss is not the best idea at this point). I can not get it to output anything at all. I have tried it in the visible field which didn't work, so I thought I would just get it to write something to the screen:

<p>some text <%# String.Format("meeee {0}", Mybool) %></p>

But I do not get any output from the inline code. the "some text" appears but no "meeee" or the bool value.

I am doing this inside a user control, at this moment but do not imagine that would be the cause.

any ideas please?

Thanks

EDIT....

OK so thanks to Freddy Rios for the reply I can get the text to appear but when I try that in:

Visible='<%= mybool %>'

I get the compilation error of:

Cannot create an object of type System.boolean from its string representation for the visible property.

I am confused as to what exactly is happening. There must be part of the process under the bonnet I don't get.

EDIT 2:

I get the error on line 123:

<fieldset class="myclass" id="projectarea" runat="server" visible='<%= ShowProjectSearchArea %>'>

ShowProjectSearchArea is my bool value, set to false.

If I double click the error in the Error List window I get the following in a popup, which I have never seen before:

  Cannot open file '%1'. It might not be in the solution.

解决方案

Try using = instead of # in your version:

<p>some text <%= String.Format("meeee {0}", Mybool) %></p>

The # is for databinding, so in the original code there must be a call to DataBind somewhere.

这篇关于asp.net在线code&LT;%#MyboolVal%GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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