473,811 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp:button that opens a new webpage?

Roy
Ok, I feel silly asking this because it seems like such a simple thing
but I haven't been able to figure it out. Is it possible to create an
asp:button that functions just like an asp:linkbutton? What I'm trying
to do is when a user clicks a button (a pushbutton) it will open a new
page (not response.redire ct but an entirely different browser window).

Seems simple, but the answer evades me. :(

Nov 19 '05 #1
4 1747
You can open windows with the javascript window.open method.
Here's more info:
http://SteveOrr.net/articles/clientsidesuite.aspx
http://msdn.microsoft.com/workshop/a...ods/open_0.asp

Some popup blockers may foil your plans however, so consider alternate
designs.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Roy" <ro**********@g mail.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Ok, I feel silly asking this because it seems like such a simple thing
but I haven't been able to figure it out. Is it possible to create an
asp:button that functions just like an asp:linkbutton? What I'm trying
to do is when a user clicks a button (a pushbutton) it will open a new
page (not response.redire ct but an entirely different browser window).

Seems simple, but the answer evades me. :(

Nov 19 '05 #2
Roy
Hey Steve, thanks for the response, I've checked out the javascript
articles you gave (and many others) and have added javascript
functionality to my webpage. Only problem is, it doesn't work!

I'm assuming it's something simple, but I'll be darned if I know what
it is. Could you eyeball this and let me know where I'm erroring?

Here's my page_load function:
*************** *********
Public Sub Page_Load (sender As Object, e As EventArgs)
Page.RegisterSt artupScript("My Script","<scrip t language=javasc ript>
function addnewrec() {
window.open(add 315.aspx,null,h eight=200,width =400,status=yes ,toolbar=no,men ubar=no,locatio n=no);}</script>"
)

If (ISPOSTBACK = FALSE) THEN
BindData()
End If
End Sub
*************** *************** **
Now, behold my mighty asp:button! ...which is not so mighty...

<asp:button OnClick="addnew rec()" text="Add New Record"
runat="server"/>

My error is " BC30456: 'addnewrec' is not a member of
'ASP.admin_aspx '."

What gives? No matter how I rework the syntax, the compiler never seems
to recognize addnewrec() as a viable function?

Thanks!

Nov 19 '05 #3
You have no quotes around the window.open parameters.
In this case you'll need to use single quotes so they don't conflict with
the double quotes you're already using.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Roy" <ro**********@g mail.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
Hey Steve, thanks for the response, I've checked out the javascript
articles you gave (and many others) and have added javascript
functionality to my webpage. Only problem is, it doesn't work!

I'm assuming it's something simple, but I'll be darned if I know what
it is. Could you eyeball this and let me know where I'm erroring?

Here's my page_load function:
*************** *********
Public Sub Page_Load (sender As Object, e As EventArgs)
Page.RegisterSt artupScript("My Script","<scrip t language=javasc ript>
function addnewrec() {
window.open(add 315.aspx,null,h eight=200,width =400,status=yes ,toolbar=no,men ubar=no,locatio n=no);}</script>"
)

If (ISPOSTBACK = FALSE) THEN
BindData()
End If
End Sub
*************** *************** **
Now, behold my mighty asp:button! ...which is not so mighty...

<asp:button OnClick="addnew rec()" text="Add New Record"
runat="server"/>

My error is " BC30456: 'addnewrec' is not a member of
'ASP.admin_aspx '."

What gives? No matter how I rework the syntax, the compiler never seems
to recognize addnewrec() as a viable function?

Thanks!

Nov 19 '05 #4
Also, add the OnClick attribute to your button tag at run time.
ASP.NET is trying to evaluate this at design time, and it sees that you have
no server side function addnewrec. It doesn't find it because this will be
a client side function, not a server side function.
Use a line of server side code this this to add the attribute at runtime:

MyButton.Attrib utes.Add("OnCli ck","addnewrec( )")

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Roy" <ro**********@g mail.com> wrote in message
news:11******** *************@g 14g2000cwa.goog legroups.com...
Hey Steve, thanks for the response, I've checked out the javascript
articles you gave (and many others) and have added javascript
functionality to my webpage. Only problem is, it doesn't work!

I'm assuming it's something simple, but I'll be darned if I know what
it is. Could you eyeball this and let me know where I'm erroring?

Here's my page_load function:
*************** *********
Public Sub Page_Load (sender As Object, e As EventArgs)
Page.RegisterSt artupScript("My Script","<scrip t language=javasc ript>
function addnewrec() {
window.open(add 315.aspx,null,h eight=200,width =400,status=yes ,toolbar=no,men ubar=no,locatio n=no);}</script>"
)

If (ISPOSTBACK = FALSE) THEN
BindData()
End If
End Sub
*************** *************** **
Now, behold my mighty asp:button! ...which is not so mighty...

<asp:button OnClick="addnew rec()" text="Add New Record"
runat="server"/>

My error is " BC30456: 'addnewrec' is not a member of
'ASP.admin_aspx '."

What gives? No matter how I rework the syntax, the compiler never seems
to recognize addnewrec() as a viable function?

Thanks!

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
14333
by: Chris Fink | last post by:
Hello, I have a datalist that contains an asp button. I have the need to pass a value that is bound to my datalist along the button when the on_click event is fired. My datalist creates a button for each row in my datasource, so each button needs to pass a unique value. My questions are: 1. How do I pass the value with the button without making it visible on the button or form. 2. Is there a way to grab this value in the button's...
3
1982
by: needin4mation | last post by:
Hi, I have an asp:button that has a ShowModalDialog script attribute added to it. When the ShowModalDialog opens the user is supposed to select some data which is then sent back to the calling .aspx page and that data sent back is placed in a hidden textbox for processing when the form posts back from the asp:button (the same button that called the ShowModalDialog windows, calls the window and then postsback). This works fine.
5
2581
JDMM
by: JDMM | last post by:
How do i access an asp page from LAN? I have installed IIS 5.1 on one of my nekwork pc named ABC (say). Then i have included the folder (named "aspeg") which contains the asp webpages inside the wwwroot folder. Then i have configured the IIS by going to Default website -> Properties->Under Directory Security, i have enabled anonymous access and have checked on "Allow IIS to control password" Now the Home Directory i have checked on "A...
1
4922
by: mazdotnet | last post by:
Hi all, I'm really stuck trying to figure the following out. I have been working on a shopping portal where you can select products from a list inside a repeater on the bottom of the page and on each row, once clicked you can enter a quantity and add it to your cart automatically on top (using UpdatePanel). Everything seems to be working fine when I created a dummy DataTable and did a bind but now that I'm actually reading the contents...
0
9728
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10402
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.