adding dynamic content to a button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven

    #1

    adding dynamic content to a button

    Hi. I am having a small problem. I am trying to add a
    dynamic attribute to a regular html button, but I also
    have a runat="server" attribute on it because at one
    point it's invisible, and I make it visible...
    Everything works when I take out runat="server", but when
    I leave it, it actually prints out lblSSN.Text rather
    than substituting it with a number. Here is the code

    <input type="button" runat="server"
    id="buttonAddGu ardian" value="Add Guardian"
    onClick="window .open('addguard ian.aspx?id=<%= lblSSN.Text%[color=blue]
    >');"/>[/color]

    I would like the HTML source look like window.open
    ('addguardian.a spx?id=12345678 9') Thank you.
  • S. Justin Gengo

    #2
    Re: adding dynamic content to a button

    Steven,

    Instead of placing the window.open parameter the way you are doing set it
    using the attributes method of the button in the codebehind page.

    buttonAddGuardi an.Attributes.A dd("onClick",
    "javascript:win dow.open('addgu ardian.aspx?id= " & lblSSN.Text & "');")

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "Steven" <stevenzilberma n@alum.rpi.edu> wrote in message
    news:08de01c360 1f$03ada470$a50 1280a@phx.gbl.. .[color=blue]
    > Hi. I am having a small problem. I am trying to add a
    > dynamic attribute to a regular html button, but I also
    > have a runat="server" attribute on it because at one
    > point it's invisible, and I make it visible...
    > Everything works when I take out runat="server", but when
    > I leave it, it actually prints out lblSSN.Text rather
    > than substituting it with a number. Here is the code
    >
    > <input type="button" runat="server"
    > id="buttonAddGu ardian" value="Add Guardian"
    > onClick="window .open('addguard ian.aspx?id=<%= lblSSN.Text%[color=green]
    > >');"/>[/color]
    >
    > I would like the HTML source look like window.open
    > ('addguardian.a spx?id=12345678 9') Thank you.[/color]


    Comment

    Working...