473,382 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problem with runat=server

Joy
Hi grou

my code is simple but not working

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa

Dim MyButton As New System.Web.UI.WebControls.Butto
Me.Controls.Add(MyButton

End Su

What is the reason that this simple code causes an error and how can I fix it

Thank
Joy
Nov 18 '05 #1
2 791
Please always include include the exact error you have when posting...

For now, my guess would be that you have to add this control inside your
server side form tag...

Patrice

--

"Joy" <an*******@discussions.microsoft.com> a écrit dans le message de
news:ED**********************************@microsof t.com...
Hi group

my code is simple but not working:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim MyButton As New System.Web.UI.WebControls.Button
Me.Controls.Add(MyButton)

End Sub

What is the reason that this simple code causes an error and how can I fix it?
Thanks
Joy


Nov 18 '05 #2
When you use the Add() method, it adds the control at the end of the page. Try replacing all the code with the following:

Dim l As New Literal
l.Text = "foo"
Me.Controls.Add(l)

Build the page, and view its source. Notice where foo appears, after the final HTML tag. Consider using AddAt(x) or a placeholder instead of Add().

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 18 '05 #3

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

Similar topics

1
by: John MacIntyre | last post by:
Hi, I am having a problem executing server side javascript. For some reason the script tag is ignored when the runat=server is combined with the src attribute. The code is being used client...
1
by: Gary Bagen | last post by:
Hello, I am working on a page transition scheme and was wondering what the quickest way is to find out which ASP.NET controls need to be inside a form with runat=server. I've determined that...
9
by: Jay | last post by:
Where is there a good article/description on why everything is runat=server. I just can't seem to grasp why ALL tags (even table tags) are runat server in dotnet. Thank You
3
by: testemail | last post by:
Hello How do I perform a variable replacement in ASP.NET when I am using the runat=server clause to generate a table - it was simple in ASP With ASP : ---------- <HTML> .... <BODY>
1
by: Gary Bagen | last post by:
Hello, I am working on a page transition scheme and was wondering what the quickest way is to find out which ASP.NET controls need to be inside a form with runat=server. I've determined that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.