Go Back   SitePoint Forums > Forum Index > Program Your Site > .NET
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jan 9, 2003, 08:40   #1
Chuckie
SitePoint Wizard
 
Join Date: Nov 2000
Location: Chico, Ca
Posts: 1,128
VB.Net Variables in Javascript

I am trying to use vb.Net vaiables in Javascript but I am having problems with it.

Here is my Code:

PHP Code:



<%@ Page Language="VB" %>
<
script runat="server">

    
Dim strDescript as String
    
    
    
      Sub Page_Load
(Sender As Object, E As EventArgs)
    
         
strDescript = "This is a test to see if the actually works!"
    
           
lbltest.text = strDescript
    
    
    
    end Sub

</script>
<html>
    <head>
    <script type="text/javascript" src="gallerypics.js"></script>
    </head>


    <body>
        <form runat="server"><asp:HyperLink runat="server" href="javascript:showPic('photos/image003.jpg','photography',480,360,'#000000','#cccccc','<%# strDescript %>','Chucks Spiecal','10/23/89');">HyperLink</asp:HyperLink>
           

<a href="javascript:showPic('photos/image003.jpg','photography',480,360,'#000000','#cccccc',' <%# strDescript %> ','Chucks Spiecal','10/23/89');"><img class="whiteborder"
           src="thumb/image003.jpg" width="120" height="89" alt="Click Me"  /></a>
           
           <asp:Label id="lbltest" runat="server">Label</asp:Label>
           
           
        </form>
    </body>
</html>

When I put the variable in the HTML Anchor tag, it just flat doesn't work.

When I put the variable in a webcontrol it parses it out, but doesn't put the content of the variable in it's place. Does anyone have a solution to this problem?

Thanks

Chuck
Chuckie is offline   Reply With Quote
Old Jan 9, 2003, 10:18   #2
jeffyjones
SitePoint Wizard
silver trophy
 
Join Date: Sep 2002
Location: Cleveland, Ohio, USA
Posts: 1,488
Use <%= strDescript %>
jeffyjones is offline   Reply With Quote
Old Jan 9, 2003, 11:38   #3
dmacanri
SitePoint Enthusiast
 
Join Date: Oct 2002
Location: Meath, Ireland
Posts: 30
<%# ... %> is only used for databinding. Otherwise, if you need to, use <%= ... %> to get the value of a simple variable.
dmacanri is offline   Reply With Quote
Old Jan 9, 2003, 12:38   #4
Chuckie
SitePoint Wizard
 
Join Date: Nov 2000
Location: Chico, Ca
Posts: 1,128
Thanks ! I knew it was something simple.
Chuckie is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 12:59.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved