1

I have an aspx page with some c# code blocks in it and I am trying to use a variable from the first block in the second block. I've tried lots of different things to make the variable public and available but haven't managed it. Can someone point out/give me a clue as to where I am going wrong please?

This is some of my code:

<%@ Page Language="C#"%>

<%
  string myVar;          
  myVar = ”Dan”;
%>

<script>

function buildHyperlinks(){
    try{
        $(<a href ='http://myServer/sites/page.aspx?params=<% Response.Write(myVar);%>'>"`
    }catch(err){
        setTimeout(buildHyperlinks(), 5000); 
    }       
}


</script>

Thanks, Dan

4

2 に答える 2

1

コード ビハインドで変数を宣言しないのはなぜですか? 次に、どこでも利用できるようにする必要があります。

于 2013-09-02T20:46:41.100 に答える