简体   繁体   中英

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. 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.

I really need to be able to debug the web application with the script running to keep coding.

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.

..........

    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:

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

c#:

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

Does that work for you?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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