Click here to Skip to main content
15,911,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My variable is
C#
public string Coordinate5a;

inside if condition i am assigning value to Coordinate5a like this:

C#
if(res==ddlnetworkName)
 {
        Coordinate5a = alLatitude[2].ToString();
 }


The Following code is inside javascript

JavaScript
var c5a = '<%=Coordinate5a%>';


But output i am getting as ''(null) when i debug the code
Posted
Updated 14-Dec-15 22:08pm
v2
Comments
Kornfeld Eliyahu Peter 15-Dec-15 3:59am    
Debug to see if you ever hit the line inside the if...
Suvendu Shekhar Giri 15-Dec-15 4:07am    
hmm.. that makes sense !
mithun286 15-Dec-15 4:08am    
Yes it is going inside the if and assigning value also but when i debug java script function the value is coming as '' (null)
Kornfeld Eliyahu Peter 15-Dec-15 4:11am    
In that case it probably the timing - the inline expressions parsed during the rendering...You may set the value too late for that...
mithun286 15-Dec-15 4:12am    
How to solve this???
what changes do i need to make?

1 solution

<dx:aspxcheckbox id="ASPxCheckBox4" text="KeyStroke" clientinstancename="KeyStroke" runat="server" xmlns:dx="#unknown">
                                                           <clientsideevents checkedchanged="function(s,e){ ShowLoadingPanel();strShowKeyStroke=s.GetChecked(); keyStroke();}" />
                                                       </dx:aspxcheckbox>
 
Share this answer
 
Comments
mithun286 15-Dec-15 5:49am    
Home.aspx

function keyStroke() {

var c5a = '<%=Coordinate5a%>';

}

This i am calling inside <body> like:

<dx:ASPxCheckBox ID="ASPxCheckBox4" Text="KeyStroke" ClientInstanceName="KeyStroke" runat="server">
<clientsideevents checkedchanged="function(s,e){ ShowLoadingPanel();strShowKeyStroke=s.GetChecked(); keyStroke();}">


Code Behind:
public string Coordinate5a;

protected void Page_Load(object sender, EventArgs e)
{
string ddlnetwork="cw";
if (ddlnetworkName== "CW")
{
Coordinate5a = "c5a";
}

}
<pre lang="c#">
<dx:ASPxCheckBox ID="ASPxCheckBox4" Text="KeyStroke" ClientInstanceName="KeyStroke" runat="server">
<clientsideevents checkedchanged="function(s,e){ ShowLoadingPanel();strShowKeyStroke=s.GetChecked(); keyStroke();}">

<pre lang="c#">

the value of Coordinate5a inside javascript i am getting as ''(null)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900