Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

asp variable in javascript

Status
Not open for further replies.

kamfl610

Programmer
Apr 15, 2003
90
US
Hi all,

I'm trying to access an asp variable in javascript. Here's the snippet of code:

Code:
<FooterTemplate>
<asp:TextBox ID="txtActivedate" runat="server" Text='01/01/2007' MaxLength="10" Width="70px"></asp:TextBox><input
type="button" runat="server" value="Cal" onclick="displayCalendar(document.getElementById('<%= txtActivedate.ClientID %>'),'mm/dd/yyyy',this);" />
</FooterTemplate>

problem when i actually view the source in the web page, I have this instead:

Code:
</td><td>&nbsp;</td><td>
<textarea name="ctl00$ContentPlaceHolder1$GridView1$ctl05$txtMessages" rows="2" cols="20" id="ctl00_ContentPlaceHolder1_GridView1_ctl05_txtMessages" style="width:400px;"></textarea>
</td><td readonly="true">
<input name="ctl00$ContentPlaceHolder1$GridView1$ctl05$txtActivedate" type="text" value="01/01/2007" maxlength="10" id="ctl00_ContentPlaceHolder1_GridView1_ctl05_txtActivedate" readonly="true" style="width:70px;" /><input name="ctl00$ContentPlaceHolder1$GridView1$ctl05$ctl00" type="button" value="Cal" onclick="displayCalendar(document.getElementById('&lt;%= txtActivedate.ClientID %>'),'mm/dd/yyyy',this);" />
</td><td>&nbsp;</td><td>&nbsp;</td>

It's treating the <% for my asp variable into less than (&lt). It's driving me crazy. How do I fix this?
 
that is an ASP.NET problem not a JS problem.

set the onClick attribute using code behind. thats the best way...

Known is handfull, Unknown is worldfull
 
Not on a calendar javascript popup. I'm looking for the actual ClientID of the textbox Active Date. It should render like the other controls and come up with the client id. I don't understand why it's treating the <% as less than but not the other %>.
 
>>I don't understand why it's treating the <% as less than but not the other %>.

that is because it is given INSIDE an ASP.NET tag. thats wht happens when u try that inside any runat server control tags (WebControls).

>>Not on a calendar javascript popup

meaning???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top