ASP Button to open link

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
 
W

Winista

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

intrader

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.
 
P

Phillip N Rounds

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
 

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top