Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem W/ Button1.Attributes.Add("onclick", "window.open

Status
Not open for further replies.

JimboD

Programmer
Jul 14, 2005
6
0
0
US
I have one button on my page that is using the folowing code to open a new browser and web site. How can I add several other buttons that go to the same page.


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Button1.Attributes.Add("onclick", "window.open( '
This works fine with one button I add another button and the folowing code

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Button1.Attributes.Add("onclick", "window.open( ' Button2.Attributes.Add("onclick", "window.open( '
Now it gives the folowing error

Control 'Button2' of type 'Button' must be placed inside a form tag with runat=server.

This is the html for this page

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="employee_list.aspx.vb" Inherits="newWindowTest.employee_list"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>employee_list</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content=" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:button id="Button1" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 224px" runat="server"
Text="Button"></asp:button></form>
<asp:Button id="Button2" style="Z-INDEX: 102; LEFT: 344px; POSITION: absolute; TOP: 264px" runat="server"
Text="Button"></asp:Button></form>
<form></form>
</body>
</HTML>

what am I missing
 
Are you creating these controls dynamically, or using drag and drop?
 
jbenson001

I am using drag and drop
 
Strange, I agree with Tom, seems the only problem is with the extra from tags. Not sure how they got there. Remove them and try again.
 
tgreer

I removed xtra form tag still prob
 
I'd be slightly concerned about how those form tags are being created. If you are using the designer to create your controls (i.e not in HTML view) then you really shouldn't be getting these problems. If you are using the HTML view, then you must have created these form tags yourselg, otherwise, you have a rather strange problem with the designer!

Just to clarify, you should one have one instance of an opening form tag and one instance of a closing form tag.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks all it was the form tags



Works now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top