Asp .Net variables

Discussion in 'Software' started by unclematty, Mar 4, 2004.

  1. unclematty

    unclematty Private First Class

    I used to be able to write a variable like this..

    I'd declare it in the head...
    Code:
    <% 
      Dim sVar 
      sVar = "Some Var"
    %>
    
    Then, later I would write it...
    <td class="<%Response.Write(sVar)%>">
    
    
    This doesnt work for me in .Net. I get an error that the variable is not declared.

    Any suggestions?
     
  2. unclematty

    unclematty Private First Class

    Nevermind, I got it. I wasnt included the runat=server in my script tags
     
  3. Kodo

    Kodo SNATCHSQUATCH

    don't forget to give it a data type
    for ex:
    dim somevar as integer

    if you don't declare a datatype, then it will be typed as variant and you want to avoid that if you can.
     
  4. unclematty

    unclematty Private First Class

    Thanks. I realized that but not before, leaving it undeclared as I would have in earlier version of ASP.

    I have some new trouble now, I am using this...

    Code:
    <%Response.Write(sTabSelected)%>
    And want to set this value at page_load. However, I cant seem to make it happen. I double click the background on design view and go to Page_Load(), in there I set the value and I still get an undeclared error.

    Any help. I appreciate your great help so far. you really are too kind.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds