Showing posts with label exception. Show all posts
Showing posts with label exception. Show all posts

Saturday, March 24, 2012

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 --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

elton_wang@.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 -->
>
>.
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
> elton_wang@.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 -->
> >.

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

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
elton_wang@dotnet.itags.org.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(Control
control)
>
System.Web.UI.WebControls.ImageButton.AddAttributesToRender
(HtmlTextWriter
>writer)
> System.Web.UI.WebControls.WebControl.RenderBeginTag
(HtmlTextWriter
>writer)
> System.Web.UI.WebControls.WebControl.Render
(HtmlTextWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter
writer)
> System.Web.UI.Control.RenderChildren(HtmlTextWriter
writer)
> System.Web.UI.Control.Render(HtmlTextWriter writer)
> System.Web.UI.Control.RenderControl(HtmlTextWriter
writer)
> System.Web.UI.Page.ProcessRequestMain()
><end code -->
>
>.
>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
> elton_wang@.hotmail.com
>
> here...
> WebForm however I
> answer for any where
> appreciated. If more
> more.
> [FileName.Length];
> Control 'Preview1' of type
> runat=server.
> type 'ImageButton' must
> control)
> System.Web.UI.WebControls.ImageButton.AddAttributesToRender
> (HtmlTextWriter
> (HtmlTextWriter
> (HtmlTextWriter writer)
> writer)
> writer)
> writer)
>

Tuesday, March 13, 2012

Thread was being aborted exception in user control

I have an .ascx user control for creating dynamic charts from a datatable, which uses an external .aspx page for rendering the chart as a .png image. The control is not functioning as expected (ie. the chart image is not being saved in the specified folder), with the containing page catching a "Thread was being aborted" exception. The containing page itself is rendered correctly, and there is no further use of Response.Redirect or Server.Transfer after the page is loaded. Could the exception arise from the statement within the code behind file of the control where the control's image source is set:
imgGDI.imageURL = "somepage.apsx"
or is the only source likely to be the previous Server.Transfer call to the containing page? I have read other threads regarding the 'Thread was being aborted' exception and Try...Catch blocks, but the solutions detailed do not seem to have any effect.
Any suggestions most welcome.The Thread being aborted exception is the natural generation of a Server.Transfer or Response.Redirect. However a Reponse.Redirect has an option to supress the exception. Response.Redirect("foo.aspx", false);
We're using Server.Transfer("foo.aspx", false). The problem seems to be intermittant at the moment though, which is why I thought the problem may be to do with the external .aspx pages being used for the image source.

Thread was being aborted thrown for background thread (win2003 ser

Hello,
Thread was being aborted exception is thrown by IIS for my asp.net
application on win2003 server. This error has not yet occured with the same
asp.net application on
windows 2000 professional computers that are also lot older and less
effective. And this error does not occure if this thread is run by console
application.
This asp.net gui application starts a background thread that mainly
reads data from ms access database (approximately 0,5 GB access db)
with oledb connection and then calculates something and writes to
another database.
I have tracked down that this exception is thrown by IIS in the
following code when the dataadapter should be filled with data from ms
access database or at least it seems that way after running three test trial
s.
OleDbDataAdapter dataadapter = new OleDbDataAdapter(command);
DataSet ds = new DataSet();
dataadapter.Fill(ds);
And this code should be totally OK as such since the same method is
run about thousand times before this exception is thrown and the
thread is terminated.
Has anyone run to same kind of problem ?
There are many questions in these newsgroups about direct and transfer
commands sending thread was being aborted, but this is not a case for
which that situation would apply. This is a new thread created by the
asp.net code and should run until the operation is finished, but does
not do that right now.
I read that IIS could unload application domain by throwing this
exception if it thinks that a crash,timeout,deadlock or memory has
been exceeded. But this should not do that since console application
on the same win2003 server runs just fine and on slower and older
win2000 machines the application also performs okey on IIS.
Also tried to change connection timeout parameter of IIS server, but
it did not help (from 120 to 1200)
Thank you in advance for reading and for possible answers that might
help me to figure a way out of this problematic situation.
BR,
JohannaWhat happens if you run this as a single thread?