Showing posts with label webform. Show all posts
Showing posts with label webform. 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 -->
> >.

Thursday, March 22, 2012

Thread execution report?

Hi, I am creating a newsletter system, and in the webform used to write and
send the newsletter I use a thread that sends all the newsletters, so that
when I write the newsletter I don't need to wait for all the mails to be
delivered, but it's the thread I launch that is responsible for the delivery
.
My question is, is there a way to have a report of the status of the deliver
y?
Since HTTP is stateless, I don't think there is a simple way to do this,
since, after I send the email and my request ends, I no longer have a way to
communicate with the thread which is still running on the server to send the
emails.
Do you have any suggestion?
Simone BusoliHave it send you an email.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
"Simone Busoli" <SimoneBusoli@.discussions.microsoft.com> wrote in message
news:B6C016E0-6099-4E60-9744-6BD7DEB0C06D@.microsoft.com...
> Hi, I am creating a newsletter system, and in the webform used to write
> and
> send the newsletter I use a thread that sends all the newsletters, so that
> when I write the newsletter I don't need to wait for all the mails to be
> delivered, but it's the thread I launch that is responsible for the
> delivery.
> My question is, is there a way to have a report of the status of the
> delivery?
> Since HTTP is stateless, I don't think there is a simple way to do this,
> since, after I send the email and my request ends, I no longer have a way
> to
> communicate with the thread which is still running on the server to send
> the
> emails.
> Do you have any suggestion?
> --
> Simone Busoli