Reputation: 23
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.
P.S. 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 %>
Upvotes: 0
Views: 115
Reputation: 2837
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?
Upvotes: 0