页面渲染输出问题 [英] problem with page render output

查看:77
本文介绍了页面渲染输出问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我创建了一个带有一些控件的页面.当我在Label的定义后放置"<% label.Text = "changed";%>"时,执行执行页面后,标签文本值不呈现.为什么?

Hi

I created a page with some controls within it.When i put "<% label.Text = "changed";%>" after definition of Label ,label text value do not render after execute page.why?

<div>
   <tagprefix:MD ID="CC"  runat="server" />
        <asp:TextBox runat="server"  ID="TextBox1"/>
        <asp:Button Text="button" ID="Button"  runat="server" onclick="Button_Click" />
        <%= "Hello..." %>

        <% label.Text = "changed"; %>                          //working fine
        <asp:Label ID="label" Text="text" runat="server" />
        <%--<% label.Text = "changed"; %>--%>                  // do not work

</div>

推荐答案

这是因为嵌入式代码块是在渲染期间执行的.请参阅 http://msdn.microsoft.com/en-us/library/ms178135.aspx .因此,如果将代码放在标签后面,则在执行代码时标签已经呈现.如果将嵌入式代码块放在标签之前,则在呈现标签之前执行该代码块.
It is because the embedded code block is executed during rendering. See http://msdn.microsoft.com/en-us/library/ms178135.aspx. Therefore if you put the code behind the label, the label is already rendered when the code is executed. If you put the embedded code block before the label it is executed before the rendering of the label.


这篇关于页面渲染输出问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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