473,416 Members | 1,721 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,416 software developers and data experts.

this.Controls.Add(ImageButton[i]) exception

Morning -

I am hoping somebody from this group can help me out here...

I have been trying to add an array of ImageButtons to my WebForm however I
keep getting an exception that I can't seem to find an answer for any where
on the net.

Any help in the right direction would be greatly appreciated. If more
code/source is need please let me know and I will post more.

thx -

CJ

<!-- Code here>
....
ImageButton [] ImageArray = new ImageButton[FileName.Length];
....
for (int i = 0; i < FileName.Length; i++)
{
ImageArray[i]= new ImageButton();
...
this.Controls.Add(ImageArray[i]);
}
....

<HTML>
....
<FORM id="display" method="post" runat="server">
...
</FORM>
</HTML>

Exception Details: System.Web.HttpException: Control 'Preview1' of type
'ImageButton' must be placed inside a form tag with runat=server.

Stack Trace:
[HttpException (0x80004005): Control 'Preview1' of type 'ImageButton' must
be placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Con trol control)
System.Web.UI.WebControls.ImageButton.AddAttribute sToRender(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.RenderBeginTa g(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTe xtWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
System.Web.UI.Page.ProcessRequestMain()

<end code --->
Nov 19 '05 #1
2 3992
Hi CJ,

If you add ImageButton to form rather than page, the
ImageButton will be placed inside form tag:

HtmlForm form = (HtmlForm)this.FindControl("Form1");

//...
form.Controls.Add(ImageArray[i]);
//...

Hope it's helpful to you.

Elton Wang

el********@hotmail.com
-----Original Message-----
Morning -

I am hoping somebody from this group can help me out here...
I have been trying to add an array of ImageButtons to my WebForm however Ikeep getting an exception that I can't seem to find an answer for any whereon the net.

Any help in the right direction would be greatly appreciated. If morecode/source is need please let me know and I will post more.
thx -

CJ

<!-- Code here>
....
ImageButton [] ImageArray = new ImageButton [FileName.Length];....
for (int i = 0; i < FileName.Length; i++)
{
ImageArray[i]= new ImageButton();
...
this.Controls.Add(ImageArray[i]);
}
....

<HTML>
....
<FORM id="display" method="post" runat="server">
...
</FORM>
</HTML>

Exception Details: System.Web.HttpException: Control 'Preview1' of type'ImageButton' must be placed inside a form tag with runat=server.
Stack Trace:
[HttpException (0x80004005): Control 'Preview1' of type 'ImageButton' mustbe placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Con trol control) System.Web.UI.WebControls.ImageButton.AddAttribute sToRender
(HtmlTextWriterwriter)
System.Web.UI.WebControls.WebControl.RenderBeginTa g (HtmlTextWriterwriter)
System.Web.UI.WebControls.WebControl.Render (HtmlTextWriter writer) System.Web.UI.Control.RenderControl(HtmlTextWriter writer) System.Web.UI.Control.RenderChildren(HtmlTextWrite r writer) System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) System.Web.UI.Page.ProcessRequestMain()

<end code --->
.

Nov 19 '05 #2
Hi,

You need to give some part of the source code and the error description.
Then only we can figure out.

Prakash.C

"Elton Wang" wrote:
Hi CJ,

If you add ImageButton to form rather than page, the
ImageButton will be placed inside form tag:

HtmlForm form = (HtmlForm)this.FindControl("Form1");

//...
form.Controls.Add(ImageArray[i]);
//...

Hope it's helpful to you.

Elton Wang

el********@hotmail.com
-----Original Message-----
Morning -

I am hoping somebody from this group can help me out

here...

I have been trying to add an array of ImageButtons to my

WebForm however I
keep getting an exception that I can't seem to find an

answer for any where
on the net.

Any help in the right direction would be greatly

appreciated. If more
code/source is need please let me know and I will post

more.

thx -

CJ

<!-- Code here>
....
ImageButton [] ImageArray = new ImageButton

[FileName.Length];
....
for (int i = 0; i < FileName.Length; i++)
{
ImageArray[i]= new ImageButton();
...
this.Controls.Add(ImageArray[i]);
}
....

<HTML>
....
<FORM id="display" method="post" runat="server">
...
</FORM>
</HTML>

Exception Details: System.Web.HttpException:

Control 'Preview1' of type
'ImageButton' must be placed inside a form tag with

runat=server.

Stack Trace:
[HttpException (0x80004005): Control 'Preview1' of

type 'ImageButton' must
be placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Con trol

control)

System.Web.UI.WebControls.ImageButton.AddAttribute sToRender
(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.RenderBeginTa g

(HtmlTextWriter
writer)
System.Web.UI.WebControls.WebControl.Render

(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter

writer)
System.Web.UI.Control.RenderChildren(HtmlTextWrite r

writer)
System.Web.UI.Control.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter

writer)
System.Web.UI.Page.ProcessRequestMain()

<end code --->
.

Nov 19 '05 #3

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

Similar topics

3
by: will | last post by:
Hi all. I've got an question about how to catch an exception. In Page_Load, I place a DataGrid, dg1, into edit mode. This will call the method called GenericGridEvent. GenericGridEvent will call...
0
by: Greg | last post by:
In my ASP.NET 1.1 Web application I have an HTTP Module that is a "global exception logger." that logs info about otherwise unhandled exceptions. It has logged the following exception 4 times...
2
by: Mardy | last post by:
Hi all, I have written a slightly modified version of the CGIHTTPServer; the difference with the module included in the standard python distrubution is that, since I know that the CGI to be...
2
by: NITIN MUNJAL | last post by:
hello, i am facing a problem in the runtime. this code is throwing exception details of which are writtten below that CODE string strConn=@"Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" +...
0
by: Bob Winters | last post by:
Hi there, I'm getting a "ThreadStateException" error whenever I place a particular DLL into my app's folder. The message is: "Current thread must be set to single thread apartment (STA) mode...
5
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I am unable to execute the following statement in my current project. The class PosExplorer is in a dll file (created by Microsoft). PosExplorer explorer = new PosExplorer() but now I get this...
3
by: sukatoa | last post by:
Exception in thread "Basic L&F File Loading Thread" java.util.concurrent.RejectedExecutionException at...
6
by: selvakumari | last post by:
i am getting an exception while end editing the 1st column 1st row of the cell(1,1) it is a combobox cell of datagridview everytime it showing following exception only on endedit dont know why...
1
by: raghudr | last post by:
Hi all, I am displaying a splash screen for which i have created a thread. Logic is: 1) i will first create a thread to display a splash screen until a big process is completed 2)then i...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...
0
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...

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.