Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Saturday, March 31, 2012

Theming custom created WebParts in ASP.NET 2.0

I have created my own WebPart using code, it is not derived from a UserControl.
Inside this WebPart I create a Calendar Control and add it to the WebParts
Control collection.

Now I want to apply a theme to this Calendar that is inside my WebPart. How
do I do that? I have created a theme and added a definition for a calendar.
The theme is applied to a calendar that is not inside the WebPart, but it is
not applied to the one inside.Hi c_kimbell,

Welcome to MSDN newsgroup.
As for the custom WebPart with a Calendar inside it, is it possible that we
define a public property on the Custom webPart which represent the Theme of
the inside Calendar control? Then, we any one assign a new value for this
property, the nested calendar's Theme value will be changed accordingly.

In addition, for .NET 2.0 and VS.NET whidbey beta issues, I suggest you
also try posting in the following web forum:

http://forums.microsoft.com/msdn/

since there are some other experienced members who may have some good ideas.

Thank you,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Thanks for suggesting the ASP.NET forums, I have posted there now as well.

Here are some more details on what I have tried;
1. On the webpart I have exposed the Calendar as a property with the name
FromCalendar.
2. I have added the following to the .skin file

<%@. Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
TagPrefix="IMK" %
<IMK:IMKDateWebPart runat="server">
<FromCalendar BackColor="#FFFFCC">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</FromCalendar>
</IMK:IMKDateWebPart
Am I on the right track?

"Steven Cheng[MSFT]" wrote:

> Hi c_kimbell,
> Welcome to MSDN newsgroup.
> As for the custom WebPart with a Calendar inside it, is it possible that we
> define a public property on the Custom webPart which represent the Theme of
> the inside Calendar control? Then, we any one assign a new value for this
> property, the nested calendar's Theme value will be changed accordingly.
> In addition, for .NET 2.0 and VS.NET whidbey beta issues, I suggest you
> also try posting in the following web forum:
> http://forums.microsoft.com/msdn/
> since there are some other experienced members who may have some good ideas.
> Thank you,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi c_kimbell,

Thanks for your followup.
As you mentioned that
=================

1. On the webpart I have exposed the Calendar as a property with the name
FromCalendar.
2. I have added the following to the .skin file

<%@. Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
TagPrefix="IMK" %
<IMK:IMKDateWebPart runat="server">
<FromCalendar BackColor="#FFFFCC">
<SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
<TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
ForeColor="#FFFFCC" />
</FromCalendar>
</IMK:IMKDateWebPart>
=======================

I'm not sure whether this will cause error since I haven't tested it.
However, IMO, I'd prefer expose a single string property on my custom web
control which represent the nested child calendar's Theme(or
stylesheettheme). Since the ASP.NET 2.0 's Theme are mostly for those
simple type properteis (such as string, int), I think just exposing a
single string type property will be much better). You can do the actual
Theme adjusting in the Property's Setter method.
How do you think ?

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
I get your point about using simple strings. One thing though, say you expose
a color, this can be specified using a name like 'Red' or it may be specified
using hex notation, like '#FFCC66'. The controls require a Color object, how
does one map between the different representations and the Color object. Are
there any utility classes I can use?

I have now done a bit more experimenting. If I declaratively add the webpart
to a webpartzone, then the theme is correctly applied. If I add the same
webpart to the zone using a catalog, the style is not applied. The catalog
I'm adding from is a custom created one, not one of the predefined types.

Any suggestions?

"Steven Cheng[MSFT]" wrote:

> Hi c_kimbell,
> Thanks for your followup.
> As you mentioned that
> =================
>
> 1. On the webpart I have exposed the Calendar as a property with the name
> FromCalendar.
> 2. I have added the following to the .skin file
> <%@. Register Assembly="IMK.WebParts" Namespace="IMK.WebParts"
> TagPrefix="IMK" %>
> <IMK:IMKDateWebPart runat="server">
> <FromCalendar BackColor="#FFFFCC">
> <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
> <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt"
> ForeColor="#FFFFCC" />
> </FromCalendar>
> </IMK:IMKDateWebPart>
> =======================
> I'm not sure whether this will cause error since I haven't tested it.
> However, IMO, I'd prefer expose a single string property on my custom web
> control which represent the nested child calendar's Theme(or
> stylesheettheme). Since the ASP.NET 2.0 's Theme are mostly for those
> simple type properteis (such as string, int), I think just exposing a
> single string type property will be much better). You can do the actual
> Theme adjusting in the Property's Setter method.
> How do you think ?
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi c_kimbell,

For those Color field, the ASP.NET runtime's ControlParser will help parse
the property value into the correct object instance. And for Color, there
is the ColorTranslator class which can be used from convert string color
value to System.Drawing.Color instance. For example:

string htmlColor = "Blue";
//or string htmlColor = "#3344ee";
// Translate htmlColor to a GDI+ Color structure.
Color myColor = ColorTranslator.FromHtml(htmlColor);

For the applying theme for custom created catalog's webpart, I'm not sure
whether this is ok. As far as I know, since the ASP.NET2.0 runtime apply
theme for controls in the page's PreInit event, so any change on Theme
after that event (for example in Page_load ..., post back event) will not
work in the first loading...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Saturday, March 24, 2012

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

Thursday, March 22, 2012

Thread issue/leak?

I am creating a worker thread from inside an aspx page and the thread does
the stuff it should do, no problem.
However, I have noticed running it in the debugger that it seems as if the
threads are not killed/garbage-collected after a thread terminates. I have a
breakpoint in the thread itself and every time it breaks, in the Threads
window I observe the new thread, but the previous thread is still there as
well. The exact same code in a windows app performs as expected, on every
break there are two threads, the main thread and the current worker thread.
The simplified code below also gives the same results, so nothing strange in
the thread itself. If I put the code in a loop of 2000 cycles and break
after the last, then there are 2000 worker threads displayed in the Threads
window.

Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
ttt.ApartmentState = Threading.ApartmentState.STA
ttt.Start()
ttt.Join()

And the simple thread:

Private Sub TheThreadProc()
Dim iii As Integer = 10
End SubThis is because you are using a Single-Threaded Apartment. There is nothing
in the thread to receive messages. When you use COM in an ASP.Net
application, you create an Interop class that is disposable, and therefore,
the thread can be killed. IOW, don't use an STA thread unless you are doing
Interop.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>I am creating a worker thread from inside an aspx page and the thread does
> the stuff it should do, no problem.
> However, I have noticed running it in the debugger that it seems as if the
> threads are not killed/garbage-collected after a thread terminates. I have
> a
> breakpoint in the thread itself and every time it breaks, in the Threads
> window I observe the new thread, but the previous thread is still there as
> well. The exact same code in a windows app performs as expected, on every
> break there are two threads, the main thread and the current worker
> thread.
> The simplified code below also gives the same results, so nothing strange
> in
> the thread itself. If I put the code in a loop of 2000 cycles and break
> after the last, then there are 2000 worker threads displayed in the
> Threads
> window.
> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
> ttt.ApartmentState = Threading.ApartmentState.STA
> ttt.Start()
> ttt.Join()
> And the simple thread:
> Private Sub TheThreadProc()
> Dim iii As Integer = 10
> End Sub
Kevin, thanks for the response, however this is not it, I tested it without
STA before I posted the problem, same result.
The true thread is doing Interop, the simple example below is not (the
simple example produces the error/issue, with or without the STA statement).

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
> This is because you are using a Single-Threaded Apartment. There is
> nothing in the thread to receive messages. When you use COM in an ASP.Net
> application, you create an Interop class that is disposable, and
> therefore, the thread can be killed. IOW, don't use an STA thread unless
> you are doing Interop.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Everybody picks their nose,
> But some people are better at hiding it.
> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>>I am creating a worker thread from inside an aspx page and the thread does
>> the stuff it should do, no problem.
>> However, I have noticed running it in the debugger that it seems as if
>> the
>> threads are not killed/garbage-collected after a thread terminates. I
>> have a
>> breakpoint in the thread itself and every time it breaks, in the Threads
>> window I observe the new thread, but the previous thread is still there
>> as
>> well. The exact same code in a windows app performs as expected, on every
>> break there are two threads, the main thread and the current worker
>> thread.
>> The simplified code below also gives the same results, so nothing strange
>> in
>> the thread itself. If I put the code in a loop of 2000 cycles and break
>> after the last, then there are 2000 worker threads displayed in the
>> Threads
>> window.
>>
>> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
>> ttt.ApartmentState = Threading.ApartmentState.STA
>> ttt.Start()
>> ttt.Join()
>>
>> And the simple thread:
>>
>> Private Sub TheThreadProc()
>> Dim iii As Integer = 10
>> End Sub
>>
>>
Are you setting the "aspcompat" attribute?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>> This is because you are using a Single-Threaded Apartment. There is
>> nothing in the thread to receive messages. When you use COM in an ASP.Net
>> application, you create an Interop class that is disposable, and
>> therefore, the thread can be killed. IOW, don't use an STA thread unless
>> you are doing Interop.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Everybody picks their nose,
>> But some people are better at hiding it.
>>
>> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
>> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>>>I am creating a worker thread from inside an aspx page and the thread
>>>does
>>> the stuff it should do, no problem.
>>> However, I have noticed running it in the debugger that it seems as if
>>> the
>>> threads are not killed/garbage-collected after a thread terminates. I
>>> have a
>>> breakpoint in the thread itself and every time it breaks, in the Threads
>>> window I observe the new thread, but the previous thread is still there
>>> as
>>> well. The exact same code in a windows app performs as expected, on
>>> every
>>> break there are two threads, the main thread and the current worker
>>> thread.
>>> The simplified code below also gives the same results, so nothing
>>> strange in
>>> the thread itself. If I put the code in a loop of 2000 cycles and break
>>> after the last, then there are 2000 worker threads displayed in the
>>> Threads
>>> window.
>>>
>>> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
>>> ttt.ApartmentState = Threading.ApartmentState.STA
>>> ttt.Start()
>>> ttt.Join()
>>>
>>> And the simple thread:
>>>
>>> Private Sub TheThreadProc()
>>> Dim iii As Integer = 10
>>> End Sub
>>>
>>>
>>
>>
Also, Chris, as you didn't post your actual code, I can't really guess what
the problem is. However, I believe you can find your answers at one or more
of the following MSDN articles (and related links):

http://msdn.microsoft.com/library/e...asp?frame=true
http://msdn.microsoft.com/library/e...asp?frame=true

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>> This is because you are using a Single-Threaded Apartment. There is
>> nothing in the thread to receive messages. When you use COM in an ASP.Net
>> application, you create an Interop class that is disposable, and
>> therefore, the thread can be killed. IOW, don't use an STA thread unless
>> you are doing Interop.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> Everybody picks their nose,
>> But some people are better at hiding it.
>>
>> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
>> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>>>I am creating a worker thread from inside an aspx page and the thread
>>>does
>>> the stuff it should do, no problem.
>>> However, I have noticed running it in the debugger that it seems as if
>>> the
>>> threads are not killed/garbage-collected after a thread terminates. I
>>> have a
>>> breakpoint in the thread itself and every time it breaks, in the Threads
>>> window I observe the new thread, but the previous thread is still there
>>> as
>>> well. The exact same code in a windows app performs as expected, on
>>> every
>>> break there are two threads, the main thread and the current worker
>>> thread.
>>> The simplified code below also gives the same results, so nothing
>>> strange in
>>> the thread itself. If I put the code in a loop of 2000 cycles and break
>>> after the last, then there are 2000 worker threads displayed in the
>>> Threads
>>> window.
>>>
>>> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
>>> ttt.ApartmentState = Threading.ApartmentState.STA
>>> ttt.Start()
>>> ttt.Join()
>>>
>>> And the simple thread:
>>>
>>> Private Sub TheThreadProc()
>>> Dim iii As Integer = 10
>>> End Sub
>>>
>>>
>>
>>
worker threads should be terminated, as you showed code of one
statement.
There would be 2000 (caller) main threads waiting for worker to be
terminated.

If you are saying worker thread (small one statement proc) is not
terminating (GC)
then Caller threads must also be alive.

Check ttt.IsAlive and do ttt.Abort() and ttt = Nothing
and test.

The (worker thread) code is being called by pageclass which is also
generated by some other asp.net parent thread (if that is calling abort
or someother stuff on the thread of pageclass this could affect).

Do let us know of your proceedings.

--
hB

Thread issue/leak?

I am creating a worker thread from inside an aspx page and the thread does
the stuff it should do, no problem.
However, I have noticed running it in the debugger that it seems as if the
threads are not killed/garbage-collected after a thread terminates. I have a
breakpoint in the thread itself and every time it breaks, in the Threads
window I observe the new thread, but the previous thread is still there as
well. The exact same code in a windows app performs as expected, on every
break there are two threads, the main thread and the current worker thread.
The simplified code below also gives the same results, so nothing strange in
the thread itself. If I put the code in a loop of 2000 cycles and break
after the last, then there are 2000 worker threads displayed in the Threads
window.
Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
ttt.ApartmentState = Threading.ApartmentState.STA
ttt.Start()
ttt.Join()
And the simple thread:
Private Sub TheThreadProc()
Dim iii As Integer = 10
End SubThis is because you are using a Single-Threaded Apartment. There is nothing
in the thread to receive messages. When you use COM in an ASP.Net
application, you create an Interop class that is disposable, and therefore,
the thread can be killed. IOW, don't use an STA thread unless you are doing
Interop.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>I am creating a worker thread from inside an aspx page and the thread does
> the stuff it should do, no problem.
> However, I have noticed running it in the debugger that it seems as if the
> threads are not killed/garbage-collected after a thread terminates. I have
> a
> breakpoint in the thread itself and every time it breaks, in the Threads
> window I observe the new thread, but the previous thread is still there as
> well. The exact same code in a windows app performs as expected, on every
> break there are two threads, the main thread and the current worker
> thread.
> The simplified code below also gives the same results, so nothing strange
> in
> the thread itself. If I put the code in a loop of 2000 cycles and break
> after the last, then there are 2000 worker threads displayed in the
> Threads
> window.
> Dim ttt As Thread = New Thread(AddressOf TheThreadProc)
> ttt.ApartmentState = Threading.ApartmentState.STA
> ttt.Start()
> ttt.Join()
> And the simple thread:
> Private Sub TheThreadProc()
> Dim iii As Integer = 10
> End Sub
>
Kevin, thanks for the response, however this is not it, I tested it without
STA before I posted the problem, same result.
The true thread is doing Interop, the simple example below is not (the
simple example produces the error/issue, with or without the STA statement).
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
> This is because you are using a Single-Threaded Apartment. There is
> nothing in the thread to receive messages. When you use COM in an ASP.Net
> application, you create an Interop class that is disposable, and
> therefore, the thread can be killed. IOW, don't use an STA thread unless
> you are doing Interop.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Everybody picks their nose,
> But some people are better at hiding it.
> "Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
> news:uo5YHs9lFHA.2916@.TK2MSFTNGP14.phx.gbl...
>
Are you setting the "aspcompat" attribute?
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>
Also, Chris, as you didn't post your actual code, I can't really guess what
the problem is. However, I believe you can find your answers at one or more
of the following MSDN articles (and related links):
http://msdn.microsoft.com/library/e...
me=true
http://msdn.microsoft.com/library/e...br />
ame=true
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Everybody picks their nose,
But some people are better at hiding it.
"Chris Botha" <chris_s_botha@.AThotmail.com> wrote in message
news:OqkgITEmFHA.708@.TK2MSFTNGP09.phx.gbl...
> Kevin, thanks for the response, however this is not it, I tested it
> without STA before I posted the problem, same result.
> The true thread is doing Interop, the simple example below is not (the
> simple example produces the error/issue, with or without the STA
> statement).
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:uhEpuHEmFHA.3300@.TK2MSFTNGP15.phx.gbl...
>
worker threads should be terminated, as you showed code of one
statement.
There would be 2000 (caller) main threads waiting for worker to be
terminated.
If you are saying worker thread (small one statement proc) is not
terminating (GC)
then Caller threads must also be alive.
Check ttt.IsAlive and do ttt.Abort() and ttt = Nothing
and test.
The (worker thread) code is being called by pageclass which is also
generated by some other asp.net parent thread (if that is calling abort
or someother stuff on the thread of pageclass this could affect).
Do let us know of your proceedings.
hB

Tuesday, March 13, 2012

Thread was being aborted error message

Hi all, I have a user control which raises an event to the parent page when
a person clicks on a link in a datagrid.
In the event handler inside the parent page I construct a url to redirect to
containing information sent from the datagrid.
It all works fine on my local machine but when I send it to the live server
I receive "The thread was being aborted"
Doing some googling suggested that I use
Response.Redirect("./myurl.aspx?ID=" + variable,false);
to allow the current thread to continue executing.
This stops the error but what I am now finding is that the redirect does not
have the querystring attributes attached to it..
e.g. instead of looking like this...
http://www.website.com/myurl.aspx?ID=5
it looks like
http://www.website.com/myurl.aspx
It's like the redirect *never* happens...
Help appreciated
Thanks
MarkPut your Response.Redirect back to the way it was, without the false
parameter.
Then wrap it in a Try/Catch statement to eat the error that's raised from
the redirect.
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Jimi" <dontspam@.me.com> wrote in message
news:uls70dBXGHA.1352@.TK2MSFTNGP05.phx.gbl...
> Hi all, I have a user control which raises an event to the parent page
> when a person clicks on a link in a datagrid.
> In the event handler inside the parent page I construct a url to redirect
> to containing information sent from the datagrid.
> It all works fine on my local machine but when I send it to the live
> server I receive "The thread was being aborted"
> Doing some googling suggested that I use
> Response.Redirect("./myurl.aspx?ID=" + variable,false);
> to allow the current thread to continue executing.
> This stops the error but what I am now finding is that the redirect does
> not have the querystring attributes attached to it..
> e.g. instead of looking like this...
> http://www.website.com/myurl.aspx?ID=5
> it looks like
> http://www.website.com/myurl.aspx
>
> It's like the redirect *never* happens...
> Help appreciated
> Thanks
> Mark
>
>
Hi Steve, you mean like this?
try
{
Response.Redirect("./myurl.aspx?ID=" + variable);
}catch (Exception ex)
{
}
I have seen other people say take the Response.Redirect("./myurl.aspx?ID=" +
variable,false) out of the try catch block...
I understand why this is hapenning but cannot understand how to fix it...
Thanks again Steve..
Cheers
Mark
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:eaqxRZEXGHA.3660@.TK2MSFTNGP04.phx.gbl...
> Put your Response.Redirect back to the way it was, without the false
> parameter.
> Then wrap it in a Try/Catch statement to eat the error that's raised from
> the redirect.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Jimi" <dontspam@.me.com> wrote in message
> news:uls70dBXGHA.1352@.TK2MSFTNGP05.phx.gbl...
>
Yes, that's what I'm suggesting. Does it work for you?
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Jimi" <dontspam@.me.com> wrote in message
news:efW%23QfEXGHA.4324@.TK2MSFTNGP03.phx.gbl...
> Hi Steve, you mean like this?
> try
> {
> Response.Redirect("./myurl.aspx?ID=" + variable);
> }catch (Exception ex)
> {
> }
> I have seen other people say take the Response.Redirect("./myurl.aspx?ID="
> + variable,false) out of the try catch block...
> I understand why this is hapenning but cannot understand how to fix it...
> Thanks again Steve..
> Cheers
> Mark
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:eaqxRZEXGHA.3660@.TK2MSFTNGP04.phx.gbl...
>
Hi Steve, no unfortunately not.
I did a try catch and caught the exception like so:
catch (Exception ex)
Output of ex.Message was Thread was being aborted.
and ex.Source = mscorlib
Thanks again for your help
Cheers
Mark
"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OlCNUwFXGHA.3848@.TK2MSFTNGP05.phx.gbl...
> Yes, that's what I'm suggesting. Does it work for you?
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Jimi" <dontspam@.me.com> wrote in message
> news:efW%23QfEXGHA.4324@.TK2MSFTNGP03.phx.gbl...
>
Hi all, in the end due to time constraints I used a JavaScript redirect and
now it all works fine.
Thanks for your help Steve :)
Cheers
Mark
"Jimi" <dontspam@.me.com> wrote in message
news:uq2px$FXGHA.752@.TK2MSFTNGP02.phx.gbl...
> Hi Steve, no unfortunately not.
> I did a try catch and caught the exception like so:
> catch (Exception ex)
> Output of ex.Message was Thread was being aborted.
> and ex.Source = mscorlib
> Thanks again for your help
> Cheers
> Mark
>
>
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:OlCNUwFXGHA.3848@.TK2MSFTNGP05.phx.gbl...
>

Thread was being aborted error message

Hi all, I have a user control which raises an event to the parent page when
a person clicks on a link in a datagrid.

In the event handler inside the parent page I construct a url to redirect to
containing information sent from the datagrid.

It all works fine on my local machine but when I send it to the live server
I receive "The thread was being aborted"

Doing some googling suggested that I use

Response.Redirect("./myurl.aspx?ID=" + variable,false);

to allow the current thread to continue executing.

This stops the error but what I am now finding is that the redirect does not
have the querystring attributes attached to it..

e.g. instead of looking like this...

http://www.website.com/myurl.aspx?ID=5

it looks like

http://www.website.com/myurl.aspx

It's like the redirect *never* happens...

Help appreciated
Thanks
MarkPut your Response.Redirect back to the way it was, without the false
parameter.
Then wrap it in a Try/Catch statement to eat the error that's raised from
the redirect.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Jimi" <dontspam@.me.com> wrote in message
news:uls70dBXGHA.1352@.TK2MSFTNGP05.phx.gbl...
> Hi all, I have a user control which raises an event to the parent page
> when a person clicks on a link in a datagrid.
> In the event handler inside the parent page I construct a url to redirect
> to containing information sent from the datagrid.
> It all works fine on my local machine but when I send it to the live
> server I receive "The thread was being aborted"
> Doing some googling suggested that I use
> Response.Redirect("./myurl.aspx?ID=" + variable,false);
> to allow the current thread to continue executing.
> This stops the error but what I am now finding is that the redirect does
> not have the querystring attributes attached to it..
> e.g. instead of looking like this...
> http://www.website.com/myurl.aspx?ID=5
> it looks like
> http://www.website.com/myurl.aspx
>
> It's like the redirect *never* happens...
> Help appreciated
> Thanks
> Mark
Hi Steve, you mean like this?

try
{
Response.Redirect("./myurl.aspx?ID=" + variable);

}catch (Exception ex)
{

}

I have seen other people say take the Response.Redirect("./myurl.aspx?ID=" +
variable,false) out of the try catch block...
I understand why this is hapenning but cannot understand how to fix it...

Thanks again Steve..
Cheers
Mark

"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:eaqxRZEXGHA.3660@.TK2MSFTNGP04.phx.gbl...
> Put your Response.Redirect back to the way it was, without the false
> parameter.
> Then wrap it in a Try/Catch statement to eat the error that's raised from
> the redirect.
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Jimi" <dontspam@.me.com> wrote in message
> news:uls70dBXGHA.1352@.TK2MSFTNGP05.phx.gbl...
>> Hi all, I have a user control which raises an event to the parent page
>> when a person clicks on a link in a datagrid.
>>
>> In the event handler inside the parent page I construct a url to redirect
>> to containing information sent from the datagrid.
>>
>> It all works fine on my local machine but when I send it to the live
>> server I receive "The thread was being aborted"
>>
>> Doing some googling suggested that I use
>>
>> Response.Redirect("./myurl.aspx?ID=" + variable,false);
>>
>> to allow the current thread to continue executing.
>>
>> This stops the error but what I am now finding is that the redirect does
>> not have the querystring attributes attached to it..
>>
>> e.g. instead of looking like this...
>>
>> http://www.website.com/myurl.aspx?ID=5
>>
>> it looks like
>>
>> http://www.website.com/myurl.aspx
>>
>>
>> It's like the redirect *never* happens...
>>
>> Help appreciated
>> Thanks
>> Mark
>>
>>
>>
Yes, that's what I'm suggesting. Does it work for you?

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Jimi" <dontspam@.me.com> wrote in message
news:efW%23QfEXGHA.4324@.TK2MSFTNGP03.phx.gbl...
> Hi Steve, you mean like this?
> try
> {
> Response.Redirect("./myurl.aspx?ID=" + variable);
> }catch (Exception ex)
> {
> }
> I have seen other people say take the Response.Redirect("./myurl.aspx?ID="
> + variable,false) out of the try catch block...
> I understand why this is hapenning but cannot understand how to fix it...
> Thanks again Steve..
> Cheers
> Mark
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:eaqxRZEXGHA.3660@.TK2MSFTNGP04.phx.gbl...
>> Put your Response.Redirect back to the way it was, without the false
>> parameter.
>> Then wrap it in a Try/Catch statement to eat the error that's raised from
>> the redirect.
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>>
>> "Jimi" <dontspam@.me.com> wrote in message
>> news:uls70dBXGHA.1352@.TK2MSFTNGP05.phx.gbl...
>>> Hi all, I have a user control which raises an event to the parent page
>>> when a person clicks on a link in a datagrid.
>>>
>>> In the event handler inside the parent page I construct a url to
>>> redirect to containing information sent from the datagrid.
>>>
>>> It all works fine on my local machine but when I send it to the live
>>> server I receive "The thread was being aborted"
>>>
>>> Doing some googling suggested that I use
>>>
>>> Response.Redirect("./myurl.aspx?ID=" + variable,false);
>>>
>>> to allow the current thread to continue executing.
>>>
>>> This stops the error but what I am now finding is that the redirect does
>>> not have the querystring attributes attached to it..
>>>
>>> e.g. instead of looking like this...
>>>
>>> http://www.website.com/myurl.aspx?ID=5
>>>
>>> it looks like
>>>
>>> http://www.website.com/myurl.aspx
>>>
>>>
>>> It's like the redirect *never* happens...
>>>
>>> Help appreciated
>>> Thanks
>>> Mark
>>>
>>>
>>>
>>
>>
Hi Steve, no unfortunately not.

I did a try catch and caught the exception like so:

catch (Exception ex)

Output of ex.Message was Thread was being aborted.
and ex.Source = mscorlib

Thanks again for your help
Cheers
Mark

"Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
news:OlCNUwFXGHA.3848@.TK2MSFTNGP05.phx.gbl...
> Yes, that's what I'm suggesting. Does it work for you?
> --
> I hope this helps,
> Steve C. Orr, MCSD, MVP
> http://SteveOrr.net
>
> "Jimi" <dontspam@.me.com> wrote in message
> news:efW%23QfEXGHA.4324@.TK2MSFTNGP03.phx.gbl...
>> Hi Steve, you mean like this?
>>
>> try
>> {
>> Response.Redirect("./myurl.aspx?ID=" + variable);
>>
>> }catch (Exception ex)
>> {
>>
>> }
>>
>> I have seen other people say take the
>> Response.Redirect("./myurl.aspx?ID=" + variable,false) out of the try
>> catch block...
>> I understand why this is hapenning but cannot understand how to fix it...
>>
>> Thanks again Steve..
>> Cheers
>> Mark
>>
>> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
>> news:eaqxRZEXGHA.3660@.TK2MSFTNGP04.phx.gbl...
>>> Put your Response.Redirect back to the way it was, without the false
>>> parameter.
>>> Then wrap it in a Try/Catch statement to eat the error that's raised
>>> from the redirect.
>>>
>>> --
>>> I hope this helps,
>>> Steve C. Orr, MCSD, MVP
>>> http://SteveOrr.net
>>>
>>>
>>>
>>> "Jimi" <dontspam@.me.com> wrote in message
>>> news:uls70dBXGHA.1352@.TK2MSFTNGP05.phx.gbl...
>>>> Hi all, I have a user control which raises an event to the parent page
>>>> when a person clicks on a link in a datagrid.
>>>>
>>>> In the event handler inside the parent page I construct a url to
>>>> redirect to containing information sent from the datagrid.
>>>>
>>>> It all works fine on my local machine but when I send it to the live
>>>> server I receive "The thread was being aborted"
>>>>
>>>> Doing some googling suggested that I use
>>>>
>>>> Response.Redirect("./myurl.aspx?ID=" + variable,false);
>>>>
>>>> to allow the current thread to continue executing.
>>>>
>>>> This stops the error but what I am now finding is that the redirect
>>>> does not have the querystring attributes attached to it..
>>>>
>>>> e.g. instead of looking like this...
>>>>
>>>> http://www.website.com/myurl.aspx?ID=5
>>>>
>>>> it looks like
>>>>
>>>> http://www.website.com/myurl.aspx
>>>>
>>>>
>>>> It's like the redirect *never* happens...
>>>>
>>>> Help appreciated
>>>> Thanks
>>>> Mark
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
Hi all, in the end due to time constraints I used a JavaScript redirect and
now it all works fine.

Thanks for your help Steve :)
Cheers
Mark
"Jimi" <dontspam@.me.com> wrote in message
news:uq2px$FXGHA.752@.TK2MSFTNGP02.phx.gbl...
> Hi Steve, no unfortunately not.
> I did a try catch and caught the exception like so:
> catch (Exception ex)
> Output of ex.Message was Thread was being aborted.
> and ex.Source = mscorlib
> Thanks again for your help
> Cheers
> Mark
>
>
> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
> news:OlCNUwFXGHA.3848@.TK2MSFTNGP05.phx.gbl...
>> Yes, that's what I'm suggesting. Does it work for you?
>>
>> --
>> I hope this helps,
>> Steve C. Orr, MCSD, MVP
>> http://SteveOrr.net
>>
>>
>> "Jimi" <dontspam@.me.com> wrote in message
>> news:efW%23QfEXGHA.4324@.TK2MSFTNGP03.phx.gbl...
>>> Hi Steve, you mean like this?
>>>
>>> try
>>> {
>>> Response.Redirect("./myurl.aspx?ID=" + variable);
>>>
>>> }catch (Exception ex)
>>> {
>>>
>>> }
>>>
>>> I have seen other people say take the
>>> Response.Redirect("./myurl.aspx?ID=" + variable,false) out of the try
>>> catch block...
>>> I understand why this is hapenning but cannot understand how to fix
>>> it...
>>>
>>> Thanks again Steve..
>>> Cheers
>>> Mark
>>>
>>> "Steve C. Orr [MVP, MCSD]" <Steve@.Orr.net> wrote in message
>>> news:eaqxRZEXGHA.3660@.TK2MSFTNGP04.phx.gbl...
>>>> Put your Response.Redirect back to the way it was, without the false
>>>> parameter.
>>>> Then wrap it in a Try/Catch statement to eat the error that's raised
>>>> from the redirect.
>>>>
>>>> --
>>>> I hope this helps,
>>>> Steve C. Orr, MCSD, MVP
>>>> http://SteveOrr.net
>>>>
>>>>
>>>>
>>>> "Jimi" <dontspam@.me.com> wrote in message
>>>> news:uls70dBXGHA.1352@.TK2MSFTNGP05.phx.gbl...
>>>>> Hi all, I have a user control which raises an event to the parent page
>>>>> when a person clicks on a link in a datagrid.
>>>>>
>>>>> In the event handler inside the parent page I construct a url to
>>>>> redirect to containing information sent from the datagrid.
>>>>>
>>>>> It all works fine on my local machine but when I send it to the live
>>>>> server I receive "The thread was being aborted"
>>>>>
>>>>> Doing some googling suggested that I use
>>>>>
>>>>> Response.Redirect("./myurl.aspx?ID=" + variable,false);
>>>>>
>>>>> to allow the current thread to continue executing.
>>>>>
>>>>> This stops the error but what I am now finding is that the redirect
>>>>> does not have the querystring attributes attached to it..
>>>>>
>>>>> e.g. instead of looking like this...
>>>>>
>>>>> http://www.website.com/myurl.aspx?ID=5
>>>>>
>>>>> it looks like
>>>>>
>>>>> http://www.website.com/myurl.aspx
>>>>>
>>>>>
>>>>> It's like the redirect *never* happens...
>>>>>
>>>>> Help appreciated
>>>>> Thanks
>>>>> Mark
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>