473,725 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vb.net create button question

Hi
I would ask this questiopn on the NG ASP but it would be days before anyone
might respond.

I am using vb.net code behind to create buttons to add to a web form.
After the buttons are created I get this error:
((Control '_ctl0' of type 'Button' must be placed inside a form tag with
runat=server.))

My Code example:
Dim mybutton As Button
Dim i As Integer
For i = 0 To 9
mybutton = New Button
mybutton.BackCo lor = Drawing.Color.B lue
mybutton.Text = (i + 1).ToString
mybutton.Width = New Unit(35)
Me.Controls.Add (mybutton)
AddHandler mybutton.Click, AddressOf mybutton_Click
Me.Controls.Add (New LiteralControl( "<BR>"))
Next

Thanks for any help
BrianDH
Nov 21 '05 #1
4 1747
Brian,

In the visual studio IDE, if you switch to the HTML view of your page and
ensure the <form> tag is placed after <body> and </form> is placed just
before </body> tag.

Once you have done this, run the page again and hopefully your problem
should be solved.

Thanks

Kevin

"BrianDH" wrote:
Hi
I would ask this questiopn on the NG ASP but it would be days before anyone
might respond.

I am using vb.net code behind to create buttons to add to a web form.
After the buttons are created I get this error:
((Control '_ctl0' of type 'Button' must be placed inside a form tag with
runat=server.))

My Code example:
Dim mybutton As Button
Dim i As Integer
For i = 0 To 9
mybutton = New Button
mybutton.BackCo lor = Drawing.Color.B lue
mybutton.Text = (i + 1).ToString
mybutton.Width = New Unit(35)
Me.Controls.Add (mybutton)
AddHandler mybutton.Click, AddressOf mybutton_Click
Me.Controls.Add (New LiteralControl( "<BR>"))
Next

Thanks for any help
BrianDH

Nov 21 '05 #2
Yes all tags are there. I never change or alter the ASP code.

"..:: Kevin ::.." wrote:
Brian,

In the visual studio IDE, if you switch to the HTML view of your page and
ensure the <form> tag is placed after <body> and </form> is placed just
before </body> tag.

Once you have done this, run the page again and hopefully your problem
should be solved.

Thanks

Kevin

"BrianDH" wrote:
Hi
I would ask this questiopn on the NG ASP but it would be days before anyone
might respond.

I am using vb.net code behind to create buttons to add to a web form.
After the buttons are created I get this error:
((Control '_ctl0' of type 'Button' must be placed inside a form tag with
runat=server.))

My Code example:
Dim mybutton As Button
Dim i As Integer
For i = 0 To 9
mybutton = New Button
mybutton.BackCo lor = Drawing.Color.B lue
mybutton.Text = (i + 1).ToString
mybutton.Width = New Unit(35)
Me.Controls.Add (mybutton)
AddHandler mybutton.Click, AddressOf mybutton_Click
Me.Controls.Add (New LiteralControl( "<BR>"))
Next

Thanks for any help
BrianDH

Nov 21 '05 #3
Brian,

I am unsure as to what could be causing this problem. I normally run into
this problem if the HTML tag that declares the control (in this case
<asp:button.. .) does not sit inside the <form> and </form> tags.

I normally never touch the tags either but on some occasions visual studio
gets a bit confused and puts the button declaration outside the form tag.

My only other suggestion would be to make sure the form tag looks something
like this:

<form id="Form1" method="post" runat="server">

Hope this helps

Kevin

"BrianDH" wrote:
Yes all tags are there. I never change or alter the ASP code.

"..:: Kevin ::.." wrote:
Brian,

In the visual studio IDE, if you switch to the HTML view of your page and
ensure the <form> tag is placed after <body> and </form> is placed just
before </body> tag.

Once you have done this, run the page again and hopefully your problem
should be solved.

Thanks

Kevin

"BrianDH" wrote:
Hi
I would ask this questiopn on the NG ASP but it would be days before anyone
might respond.

I am using vb.net code behind to create buttons to add to a web form.
After the buttons are created I get this error:
((Control '_ctl0' of type 'Button' must be placed inside a form tag with
runat=server.))

My Code example:
Dim mybutton As Button
Dim i As Integer
For i = 0 To 9
mybutton = New Button
mybutton.BackCo lor = Drawing.Color.B lue
mybutton.Text = (i + 1).ToString
mybutton.Width = New Unit(35)
Me.Controls.Add (mybutton)
AddHandler mybutton.Click, AddressOf mybutton_Click
Me.Controls.Add (New LiteralControl( "<BR>"))
Next

Thanks for any help
BrianDH

Nov 21 '05 #4
Brian,

My answer had be the same as from Kevin, so maybe you can look again.
And otherwise show us that HTML part.

Cor
Nov 21 '05 #5

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

Similar topics

4
4150
by: Peeter Ups | last post by:
I have several tables in my database. I use these to create 'quotations' that show product code, description, selling price and quantity required. Users can enter as many lines as possible and a running $ total is updated after each line is updated. At the end of the 'quote' I simply want to press a button, clear the inputted data and restart a new 'quotation'. Any help would be appreciated. I just don't know what code to put against...
7
8864
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
3
417
by: Richard Skopal | last post by:
In .NET Windows forms I can create a metafile using this code: Graphics grph = aControl.CreateGraphics(); IntPtr ipHDC = grph.GetHdc(); Metafile mf = new Metafile(aImgFilePath, ipHDC, EmfType.EmfOnly); grph.ReleaseHdc(ipHDC); grph.Dispose(); grph = Graphics.FromImage(mf); grph.DrawRectangle(aPen, 10, 10, 100, 120); grph.Dispose();
5
5431
by: Wonder | last post by:
How can I create or use the msgobx to show a message without a default button. The user has explicity to click on the button, so the msgbox closes it. Thanks,
3
17258
by: The Woo | last post by:
Can one programatically create a file folder which has the same name as a key field, using a command button? Or, Can there be a a command button which opens up a directory tree to a specified location. I'm thinking this is a visual basic-related question? Why? I have a client tracking database. When the client's record is
4
12438
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
8
3759
by: William Foster | last post by:
Good evening all, I am creating a program with the ability to select an option from a ComboBox which will then create a secondary list of options in a CheckedListBox. Previously when I have needed to create multiples of this type of user option I have simply hard coded three or four set options for the user. However, I would like to have the option for the user to have as many options available as they like. In order to do this I...
7
3488
by: Wiebe Tijsma | last post by:
Hi, I'm using C# + webDAV to create a draft message to be sent in a user's Drafts folder. I can create the message successfully, however when I open the message in outlook, it doesn't show the 'send' button, (only 'reply' etc as if it was a received message). I'm using exchange explorer to see the difference in webDAV properties
7
11358
by: Matt | last post by:
Hi all, I'm trying to create a system where it reads a number of records from a database and then creates a row in the GUI that contains a single field from the database and a button that has a reference to the record. This way, once the task has been accomplished, the button can be pressed next to the field and a time-stamp is placed into the database. Can anyone point me in the direction of either a tutorial or
1
2792
by: Akino877 | last post by:
Hello, I have a question regarding Java and Swing programming I wonder if I could ask the forum for some help. I have a JPanel that has a couple of radio buttons and an "OK/Next" button on it. When a radio button wass selected and "OK/Next" was clicked on, I was able to write some code inside the "ActionPerformed" method to verify that the radio button was selected as intended. But that was only a quick test to see that things worked. ...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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
9113
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
8097
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
6702
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
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
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...
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
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.