Results 1 to 3 of 3

Thread: accessing C# variable in ASPX HTML code ..

  1. #1

    Thread Starter
    Addicted Member chander's Avatar
    Join Date
    Nov 2000
    Location
    New Delhi , India
    Posts
    225

    accessing C# variable in ASPX HTML code ..

    can some one tell me how i can access C # code variable in ASPX 's HTML Design .. like suppose i have some value in C # code and i want to show or access it in Java Script or VB Script .. how i can do that ?? based on some Server side variable data i want to do some thing at client end .. wats the way for tht ??


    ne one can put some light on it ??
    Chander
    Email:[email protected]

  2. #2
    Junior Member
    Join Date
    Feb 2003
    Posts
    16
    Here's how I've done it in VB.net:

    In the code-behind, declare a public variable at the top of the page (where you declare your controls), like:

    Public strVariable As String

    Then on the aspx page you need to put a tag like this:

    <%# strVariable %>

    In my experience, this only seems to work if you call the Page.Databind method in the Page_Load sub.

    Let me know if it works for you.

  3. #3
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    u can hard code a script in java which when the page is created creates a var in that java script and puts there the variable
    \m/\m/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width