adding dynamic content to a button

  • Thread starter Thread starter Steven
  • Start date Start date
S

Steven

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="buttonAddGuardian" value="Add Guardian"
onClick="window.open('addguardian.aspx?id=<%=lblSSN.Text%

I would like the HTML source look like window.open
('addguardian.aspx?id=123456789') Thank you.
 
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.

buttonAddGuardian.Attributes.Add("onClick",
"javascript:window.open('addguardian.aspx?id=" & lblSSN.Text & "');")

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Back
Top