ASP Button to open link

  • Thread starter Thread starter Coolsat
  • Start date Start date
C

Coolsat

I need to do something simple but am new to asp.net. I want to add a
button to my page and when selected, to open a url in a seperate page.
The more I google how to do this, I keep seeing to do it via javascript
with window.open but the problem is, I need to build the url dynamicaly
thru code. I have the url as a string in vb. Is there a command I can
enter under the button click event to do this?

Thanks
 
You can build that piece of JS on post back event of the button and use
RegisterClientScriptBlock to put the script on page which will get executed
 
I need to do something simple but am new to asp.net. I want to add a
button to my page and when selected, to open a url in a seperate page.
The more I google how to do this, I keep seeing to do it via javascript
with window.open but the problem is, I need to build the url dynamicaly
thru code. I have the url as a string in vb. Is there a command I can
enter under the button click event to do this?

Thanks
Yes, do it like you would in Asp using <%= url %> inside the button html.
 
Coolsat said:
I need to do something simple but am new to asp.net. I want to add a
button to my page and when selected, to open a url in a seperate page.
The more I google how to do this, I keep seeing to do it via javascript
with window.open but the problem is, I need to build the url dynamicaly
thru code. I have the url as a string in vb. Is there a command I can
enter under the button click event to do this?

Thanks
Page.Response.Redirect( YourNewURL ) will take you to the new page
 
Thanks, you do not know how hard it was to find out something this
simple!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top