简体   繁体   English

如何在类型<%= value%>的块中强制执行值分配

[英]How to force execution of value assignment in blocks of type <%=value%>

is there a directive or a instruction to force the execution of the blocks of type <%=value%> in webpages?, because i have a web project in which i have a block of that type and it just evaluates the very first time (when value is ""), but if i change the value of the variable value, which is a public field of type string, within a button the content doesn't evaluates , i am using value to insert a script. 是否存在强制执行网页中<%= value%>类型的块的指令或指令?,因为我有一个Web项目,其中有一个该类型的块,并且它只是在第一次评估(当value为“”时),但是如果我更改变量value的值,变量value是string类型的公共字段,则在按钮内内容不求值,我正在使用value插入脚本。 I uploaded a copy of my aspx to my web server and the code works fine, but the problem i have is that it doesn't work while i am debugging, value is never evaluated and the script block is never inserted. 我将我的aspx的副本上载到了Web服务器,并且代码工作正常,但是我遇到的问题是,当我调试时它不起作用,永远不会评估值并且永远不会插入脚本块。

I really need to be able to debug the web application with the script running to keep coding. 我确实需要能够运行脚本来调试Web应用程序以保持编码。

Regards. 问候。

PS I really need to use this method , because the ScriptManager's RegisterClientScriptBlock and RegisterStartupScript for me are useless on previous versions of Internet Explorer. PS我真的需要使用此方法,因为在Internet Explorer的早期版本中,ScriptManager的RegisterClientScriptBlock和RegisterStartupScript对我而言是无用的。

.......... ..........

    public string value = "";

    protected void Button1_Click(object sender, EventArgs e)
    {
        //Just a silly example of a script.
        value = "<script type=\"text/javascript\">alert(Add(3,4));</script" + ">";

    }

......... ......

<script type="text/javascript">
    function Add(number1, number2) {
        return (number1 + number2);
    }

 </script>

<%=value %>

aspx: aspx:

<asp:Literal ID="Literal1" runat="server"></asp:Literal>

c#: C#:

Literal1.Text = "<script type=\"text/javascript\">alert(Add(3,4));</script" + ">";

Does that work for you? 那对你有用吗?

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

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