Showing posts with label behaviour. Show all posts
Showing posts with label behaviour. Show all posts

Saturday, March 31, 2012

Strang behaviour of multiselection Listbox

Hello,

i´d like to get access to the selected items of my listbox...

I did this in a loop, but I get only acces to the first selected item of the Listbox.

Has anyone solved the same problem? I really need help. Thx in advance.

Code (VB.net):

dim el as listitemfor each el in mylistbox.Items if el.selected then 'do something end ifnext

Give this a try...

 iCnt = 0 Dim li As ListItem For Each li In myListBox.Items If li.Selected Then iCnt += 1 Next If iCnt <> 0 Then Dim i As Integer iCnt = myListBox.Items.Count For i = 0 To iCnt - 1 If myListBox.Items(i).Selected Then 'Do Something End If Next
 End If
 Zath

Still the same problemSad
I´m sad...

But thank you for the try...

That shouldn't be.

Do you have this line in there?

If myListBox.Items(i).Selected Then

Zath


Yes...

No matter what I do, the first selected item returns true for .selected

the next ones return false...


ListBoxes (and CheckBoxLists) expose a new property called "GetSelectedIndices()"

So you can say

Dim LI As ListItem
For Each idx As Int32 in mylistbox.GetSelectedIndices()
LI = mylistbox.Items(idx)
'Do what you need to do with this selected list item
Next

*If* that doesn't work for you, and there is absolutely no reason why this code or the code you posted shouldn't... then you have other issues, like for instance, re-binding the list on every page load (which would "reset" the listboxbefore your event handler got a hold of the control)


I´m working on 1.1 so that the above function is not available for me...


But I will check the second issue. Thanks for the hint...


That did the trick... Sorry for the wasting of your time...

Did a wrong binding on PostBacks so I killed all of the selections except of one in the listbox...

*smashing head against the next wall*


i can't speak for the others replying on this topic... but you didn't/aren't wasting my time... glad to help out...

the whole binding cylce is a huge "gotcha" in .NET, we've all had our battles with it


(this is where you tell them "but it sure is great thatEasyListBox doesn't have that problem" Big Smile )

Strange behavior

Hello guys,
I have a strange behaviour in my asp.net web page. My page
contains a datagrid control, which has another nested
datagrid as a user control. It works very well, when the
user expands the + button or closes it with the same
buton. However when I do this several times successively
then suddenly I got the error message:
Object reference not set to an instance of an object.
objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
(0).FindControl("lblInvoiceDate"), Label).Text
When I do a refresh then it sees the label control again.
I am somehow why this is happening. Can somebody
help?
ThanksBy looking at this code, all one could really say is that:
objGetDailyStoreQuantitySold could be Nothing.
e could be Nothing.
e.Item could be Nothing
e.Item.Cells could be Nothing
...
etc.
You'll need to show a little more code or step through with a debugger
to get more details. Know what I mean?
Scott
http://www.OdeToCode.com/blogs/scott/
On Thu, 10 Feb 2005 08:01:10 -0800, "anonymous"
<anonymous@.discussions.microsoft.com> wrote:

>Hello guys,
>I have a strange behaviour in my asp.net web page. My page
>contains a datagrid control, which has another nested
>datagrid as a user control. It works very well, when the
>user expands the + button or closes it with the same
>buton. However when I do this several times successively
>then suddenly I got the error message:
>Object reference not set to an instance of an object.
>objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
>(0).FindControl("lblInvoiceDate"), Label).Text
>
>When I do a refresh then it sees the label control again.
>I am somehow why this is happening. Can somebody
>help?
>Thanks

Strange behavior

Hello guys,

I have a strange behaviour in my asp.net web page. My page
contains a datagrid control, which has another nested
datagrid as a user control. It works very well, when the
user expands the + button or closes it with the same
buton. However when I do this several times successively
then suddenly I got the error message:

Object reference not set to an instance of an object.
objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
(0).FindControl("lblInvoiceDate"), Label).Text

When I do a refresh then it sees the label control again.
I am somehow confused why this is happening. Can somebody
help?

ThanksBy looking at this code, all one could really say is that:

objGetDailyStoreQuantitySold could be Nothing.
e could be Nothing.
e.Item could be Nothing
e.Item.Cells could be Nothing
...
etc.

You'll need to show a little more code or step through with a debugger
to get more details. Know what I mean?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 10 Feb 2005 08:01:10 -0800, "anonymous"
<anonymous@.discussions.microsoft.com> wrote:

>Hello guys,
>I have a strange behaviour in my asp.net web page. My page
>contains a datagrid control, which has another nested
>datagrid as a user control. It works very well, when the
>user expands the + button or closes it with the same
>buton. However when I do this several times successively
>then suddenly I got the error message:
>Object reference not set to an instance of an object.
>objGetDailyStoreQuantitySold.StartDate = CType(e.Item.Cells
>(0).FindControl("lblInvoiceDate"), Label).Text
>
>When I do a refresh then it sees the label control again.
>I am somehow confused why this is happening. Can somebody
>help?
>Thanks

Wednesday, March 28, 2012

Strange Behaviour

Hi,
I have developed a multi-frame web application with asp.net in c#. One frame
contains an embedded windows media 9 player for playing .wmv files. While
there is a file loaded in the player the other frames do not reliably
refresh.
Specifivally, if I try to refresh a page where I have overridden the Render
method, IE will stall. My attempts to debug this seem to indicate that this
stalling occurs before any code is excecuted. Refreshing the player frame
allows the stalled frame to load properly. When no file is open in the
player frame, everything works fine. This does not occur for asp.net pages
that do not override the render method, or simple html pages.
The page that causes this problem performs a SQL select in its render
method. It seems that this does not occur if there is no select in Render.
I have no idea what could be causing this. Any ideas would be greatly
appreciated.
thanks,
Grace SainsburyHi
Perhaps because the file in the player is still loading?
I did a test and no problems: http://213.190.104.211/
P.S Low bandwidth so it can take time to load...
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"Grace Sainsbury" <grace@.multimediatranscripts.com> wrote in message
news:jjtrc.173$Nb4.7551@.news20.bellglobal.com...
> Hi,
> I have developed a multi-frame web application with asp.net in c#. One
> frame
> contains an embedded windows media 9 player for playing .wmv files. While
> there is a file loaded in the player the other frames do not reliably
> refresh.
> Specifivally, if I try to refresh a page where I have overridden the
> Render
> method, IE will stall. My attempts to debug this seem to indicate that
> this
> stalling occurs before any code is excecuted. Refreshing the player frame
> allows the stalled frame to load properly. When no file is open in the
> player frame, everything works fine. This does not occur for asp.net pages
> that do not override the render method, or simple html pages.
> The page that causes this problem performs a SQL select in its render
> method. It seems that this does not occur if there is no select in Render.
> I have no idea what could be causing this. Any ideas would be greatly
> appreciated.
> thanks,
> Grace Sainsbury
>
"Vidar Petursson" <thekingYoUKnOwWhatToDoHEREeh@.icysoft.com> wrote in message news:<uAh2$I5
PEHA.2132@.TK2MSFTNGP11.phx.gbl>...
> Hi
> Perhaps because the file in the player is still loading?
> I did a test and no problems: http://213.190.104.211/
> P.S Low bandwidth so it can take time to load...
>
The problem occurs even when the entire file has been loaded -- i.e.
media pler is playing from its cache. With further experimentation, I
noticed that changing the focus away from IE, then returning causes
the refresh to complete.
thaks,
grace
Grace,
In my opinion I would try to duplicate the issue on another machine. This wo
uld eliminate your video and or system as a contributing factor. Is this for
Internet Explorer and if so which version are you using? I'm pretty certain
that the code running on the server is irrelevant unless the frame is hung
up while processing that frame.
Good Luck!
-Calvin Luttrell
ProjectThunder.com

> I have developed a multi-frame web application with asp.net in c#. One fra
me
> contains an embedded windows media 9 player for playing .wmv files. While
> there is a file loaded in the player the other frames do not reliably
> refresh.
>
> Specifivally, if I try to refresh a page where I have overridden the Rende
r
> method, IE will stall. My attempts to debug this seem to indicate that thi
s
> stalling occurs before any code is excecuted. Refreshing the player frame
> allows the stalled frame to load properly. When no file is open in the
> player frame, everything works fine. This does not occur for asp.net pages
> that do not override the render method, or simple html pages.
>
> The page that causes this problem performs a SQL select in its render
> method. It seems that this does not occur if there is no select in Render.
>
> I have no idea what could be causing this. Any ideas would be greatly
> appreciated.

Strange Behaviour

I have a set of aspx pages created using VSNET 2003/VB. The web site
includes a java based menu. For a specific selection I need to change the
value of a variable in a common class. I set the menu app to call a special
aspx page whose only purpose is to set the class variable and then transfer
to the main aspx page. The initial page originally had only the following
code:
========================================
====
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CommonClass.strCallFrom = "User"
Server.Transfer("frmFindBand.aspx")
End Sub
========================================
=================
That does not work - the CommonClass.strCallFrom variable is not getting
set? Any ideas as to why this is failing?
TIA
WayneWayne,
Welcome to the web development world. Once you leave a page, it doesn't
exist anymore. Neither there is CommonClass instance, unless you took
special care to make it persistent. You should save the variable in one of a
few persistent storages, for example in a session variable.
Eliyahu
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
> I have a set of aspx pages created using VSNET 2003/VB. The web site
> includes a java based menu. For a specific selection I need to change the
> value of a variable in a common class. I set the menu app to call a
special
> aspx page whose only purpose is to set the class variable and then
transfer
> to the main aspx page. The initial page originally had only the following
> code:
> ========================================
====
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> CommonClass.strCallFrom = "User"
> Server.Transfer("frmFindBand.aspx")
> End Sub
> ========================================
=================
> That does not work - the CommonClass.strCallFrom variable is not getting
> set? Any ideas as to why this is failing?
>
> TIA
>
> Wayne
>
Is the strCallFrom is a static variable or instance variable? If its not
static variable, I do not see any code to instantiate the CommonClass
object?
Kumar Reddi
http://kumarreddi.blogspot.com
"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
> I have a set of aspx pages created using VSNET 2003/VB. The web site
> includes a java based menu. For a specific selection I need to change the
> value of a variable in a common class. I set the menu app to call a
special
> aspx page whose only purpose is to set the class variable and then
transfer
> to the main aspx page. The initial page originally had only the following
> code:
> ========================================
====
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> CommonClass.strCallFrom = "User"
> Server.Transfer("frmFindBand.aspx")
> End Sub
> ========================================
=================
> That does not work - the CommonClass.strCallFrom variable is not getting
> set? Any ideas as to why this is failing?
>
> TIA
>
> Wayne
>
Note that static variables have application scope as opposed to session.
That means the two sessions while overwrite each other setting.
Eliyahu
"Kumar Reddi" <kumarreddi@.REMOVETHIS.gmail.com> wrote in message
news:%23E8uvTnIFHA.2752@.TK2MSFTNGP12.phx.gbl...
> Is the strCallFrom is a static variable or instance variable? If its not
> static variable, I do not see any code to instantiate the CommonClass
> object?
> --
> Kumar Reddi
> http://kumarreddi.blogspot.com
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
the
> special
> transfer
following
>
Thanks for the replies guys but I really don't understand the need to
instance the class? If I add a button to the page and issue the transfer
from the click event, things work fine? What is different (I will readily
admit that I have a poor grasp of OO)?
Throughout the other 20+ pages I regularly set a CommonClass variable and
then use it in another page. I thought that was the whole idea of a common
class?
Any education is much appreciated.
Wayne
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OKCW2SnIFHA.2728@.TK2MSFTNGP09.phx.gbl...
> Wayne,
> Welcome to the web development world. Once you leave a page, it doesn't
> exist anymore. Neither there is CommonClass instance, unless you took
> special care to make it persistent. You should save the variable in one of
a
> few persistent storages, for example in a session variable.
> Eliyahu
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
the
> special
> transfer
following
>
You won't see a problem until there are simultaneous user's making
requests to your web application. You are using a single location to
store a piece of data for all users. Their requests will start
overwriting this single location with data for each request. Depending
on the timing user A could get user B's results or user B might get
user A's results.
It's always good to keep request state as close to the request as
possible. Don't try to take shortcuts by sticking a piece of data in a
common class and hope that when something later happens it still finds
the data there.
The Context.Items collection is a good place to store the information
you need to carry around.
Scott
http://www.OdeToCode.com/blogs/scott/
On Sun, 6 Mar 2005 11:10:53 -0700, "Wayne Wengert"
<wayneDONTWANTSPAM@.wengert.com> wrote:

>Thanks for the replies guys but I really don't understand the need to
>instance the class? If I add a button to the page and issue the transfer
>from the click event, things work fine? What is different (I will readily
>admit that I have a poor grasp of OO)?
>Throughout the other 20+ pages I regularly set a CommonClass variable and
>then use it in another page. I thought that was the whole idea of a common
>class?
>Any education is much appreciated.
>
Scott;
Thanks for the information. I think I am beginning to see my error here. The
Common Class information exists once for my application and if User A sets a
value in variable "X", any user asking for that variable will get that new
value? This was my first attempt at using a common class and I think I went
way overboard. I'll go back and change all use of the common class variables
to Session objects instead and just use the common class for constant values
like connection strings. Does that sound right?
Wayne
"Scott Allen" <scott@.nospam.odetocode.com> wrote in message
news:f7lm21phif382dg7fl45ee4rfrdpktgn8f@.
4ax.com...
> You won't see a problem until there are simultaneous user's making
> requests to your web application. You are using a single location to
> store a piece of data for all users. Their requests will start
> overwriting this single location with data for each request. Depending
> on the timing user A could get user B's results or user B might get
> user A's results.
> It's always good to keep request state as close to the request as
> possible. Don't try to take shortcuts by sticking a piece of data in a
> common class and hope that when something later happens it still finds
> the data there.
> The Context.Items collection is a good place to store the information
> you need to carry around.
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
> On Sun, 6 Mar 2005 11:10:53 -0700, "Wayne Wengert"
> <wayneDONTWANTSPAM@.wengert.com> wrote:
>
common
>
Hi Wayne:
Yes, that's what can happen with Shared fields in VB.NET.
Like I say, Context.Items can be just as useful as Session if you need
information to stick around during a Server.Transfer
Scott
http://www.OdeToCode.com/blogs/scott/
On Sun, 6 Mar 2005 13:58:41 -0700, "Wayne Wengert"
<wayneDONTWANTSPAM@.wengert.com> wrote:

>Scott;
>Thanks for the information. I think I am beginning to see my error here. Th
e
>Common Class information exists once for my application and if User A sets
a
>value in variable "X", any user asking for that variable will get that new
>value? This was my first attempt at using a common class and I think I went
>way overboard. I'll go back and change all use of the common class variable
s
>to Session objects instead and just use the common class for constant value
s
>like connection strings. Does that sound right?
>Wayne
>

Strange Behaviour

I have a set of aspx pages created using VSNET 2003/VB. The web site
includes a java based menu. For a specific selection I need to change the
value of a variable in a common class. I set the menu app to call a special
aspx page whose only purpose is to set the class variable and then transfer
to the main aspx page. The initial page originally had only the following
code:
============================================
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CommonClass.strCallFrom = "User"

Server.Transfer("frmFindBand.aspx")

End Sub

================================================== =======

That does not work - the CommonClass.strCallFrom variable is not getting
set? Any ideas as to why this is failing?

TIA

WayneWayne,

Welcome to the web development world. Once you leave a page, it doesn't
exist anymore. Neither there is CommonClass instance, unless you took
special care to make it persistent. You should save the variable in one of a
few persistent storages, for example in a session variable.

Eliyahu

"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
> I have a set of aspx pages created using VSNET 2003/VB. The web site
> includes a java based menu. For a specific selection I need to change the
> value of a variable in a common class. I set the menu app to call a
special
> aspx page whose only purpose is to set the class variable and then
transfer
> to the main aspx page. The initial page originally had only the following
> code:
> ============================================
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> CommonClass.strCallFrom = "User"
> Server.Transfer("frmFindBand.aspx")
> End Sub
> ================================================== =======
> That does not work - the CommonClass.strCallFrom variable is not getting
> set? Any ideas as to why this is failing?
>
> TIA
>
> Wayne
Is the strCallFrom is a static variable or instance variable? If its not
static variable, I do not see any code to instantiate the CommonClass
object?

--
Kumar Reddi
http://kumarreddi.blogspot.com

"Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
> I have a set of aspx pages created using VSNET 2003/VB. The web site
> includes a java based menu. For a specific selection I need to change the
> value of a variable in a common class. I set the menu app to call a
special
> aspx page whose only purpose is to set the class variable and then
transfer
> to the main aspx page. The initial page originally had only the following
> code:
> ============================================
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> CommonClass.strCallFrom = "User"
> Server.Transfer("frmFindBand.aspx")
> End Sub
> ================================================== =======
> That does not work - the CommonClass.strCallFrom variable is not getting
> set? Any ideas as to why this is failing?
>
> TIA
>
> Wayne
Note that static variables have application scope as opposed to session.
That means the two sessions while overwrite each other setting.

Eliyahu

"Kumar Reddi" <kumarreddi@.REMOVETHIS.gmail.com> wrote in message
news:%23E8uvTnIFHA.2752@.TK2MSFTNGP12.phx.gbl...
> Is the strCallFrom is a static variable or instance variable? If its not
> static variable, I do not see any code to instantiate the CommonClass
> object?
> --
> Kumar Reddi
> http://kumarreddi.blogspot.com
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
> > I have a set of aspx pages created using VSNET 2003/VB. The web site
> > includes a java based menu. For a specific selection I need to change
the
> > value of a variable in a common class. I set the menu app to call a
> special
> > aspx page whose only purpose is to set the class variable and then
> transfer
> > to the main aspx page. The initial page originally had only the
following
> > code:
> > ============================================
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > CommonClass.strCallFrom = "User"
> > Server.Transfer("frmFindBand.aspx")
> > End Sub
> > ================================================== =======
> > That does not work - the CommonClass.strCallFrom variable is not getting
> > set? Any ideas as to why this is failing?
> > TIA
> > Wayne
Thanks for the replies guys but I really don't understand the need to
instance the class? If I add a button to the page and issue the transfer
from the click event, things work fine? What is different (I will readily
admit that I have a poor grasp of OO)?

Throughout the other 20+ pages I regularly set a CommonClass variable and
then use it in another page. I thought that was the whole idea of a common
class?

Any education is much appreciated.

Wayne

"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:OKCW2SnIFHA.2728@.TK2MSFTNGP09.phx.gbl...
> Wayne,
> Welcome to the web development world. Once you leave a page, it doesn't
> exist anymore. Neither there is CommonClass instance, unless you took
> special care to make it persistent. You should save the variable in one of
a
> few persistent storages, for example in a session variable.
> Eliyahu
> "Wayne Wengert" <wayneDONTWANTSPAM@.wengert.com> wrote in message
> news:usT4CLmIFHA.588@.TK2MSFTNGP15.phx.gbl...
> > I have a set of aspx pages created using VSNET 2003/VB. The web site
> > includes a java based menu. For a specific selection I need to change
the
> > value of a variable in a common class. I set the menu app to call a
> special
> > aspx page whose only purpose is to set the class variable and then
> transfer
> > to the main aspx page. The initial page originally had only the
following
> > code:
> > ============================================
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > CommonClass.strCallFrom = "User"
> > Server.Transfer("frmFindBand.aspx")
> > End Sub
> > ================================================== =======
> > That does not work - the CommonClass.strCallFrom variable is not getting
> > set? Any ideas as to why this is failing?
> > TIA
> > Wayne
You won't see a problem until there are simultaneous user's making
requests to your web application. You are using a single location to
store a piece of data for all users. Their requests will start
overwriting this single location with data for each request. Depending
on the timing user A could get user B's results or user B might get
user A's results.

It's always good to keep request state as close to the request as
possible. Don't try to take shortcuts by sticking a piece of data in a
common class and hope that when something later happens it still finds
the data there.

The Context.Items collection is a good place to store the information
you need to carry around.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sun, 6 Mar 2005 11:10:53 -0700, "Wayne Wengert"
<wayneDONTWANTSPAM@.wengert.com> wrote:

>Thanks for the replies guys but I really don't understand the need to
>instance the class? If I add a button to the page and issue the transfer
>from the click event, things work fine? What is different (I will readily
>admit that I have a poor grasp of OO)?
>Throughout the other 20+ pages I regularly set a CommonClass variable and
>then use it in another page. I thought that was the whole idea of a common
>class?
>Any education is much appreciated.
Scott;

Thanks for the information. I think I am beginning to see my error here. The
Common Class information exists once for my application and if User A sets a
value in variable "X", any user asking for that variable will get that new
value? This was my first attempt at using a common class and I think I went
way overboard. I'll go back and change all use of the common class variables
to Session objects instead and just use the common class for constant values
like connection strings. Does that sound right?

Wayne

"Scott Allen" <scott@.nospam.odetocode.com> wrote in message
news:f7lm21phif382dg7fl45ee4rfrdpktgn8f@.4ax.com...
> You won't see a problem until there are simultaneous user's making
> requests to your web application. You are using a single location to
> store a piece of data for all users. Their requests will start
> overwriting this single location with data for each request. Depending
> on the timing user A could get user B's results or user B might get
> user A's results.
> It's always good to keep request state as close to the request as
> possible. Don't try to take shortcuts by sticking a piece of data in a
> common class and hope that when something later happens it still finds
> the data there.
> The Context.Items collection is a good place to store the information
> you need to carry around.
> --
> Scott
> http://www.OdeToCode.com/blogs/scott/
>
> On Sun, 6 Mar 2005 11:10:53 -0700, "Wayne Wengert"
> <wayneDONTWANTSPAM@.wengert.com> wrote:
> >Thanks for the replies guys but I really don't understand the need to
> >instance the class? If I add a button to the page and issue the transfer
> >from the click event, things work fine? What is different (I will readily
> >admit that I have a poor grasp of OO)?
> >Throughout the other 20+ pages I regularly set a CommonClass variable and
> >then use it in another page. I thought that was the whole idea of a
common
> >class?
> >Any education is much appreciated.
Hi Wayne:

Yes, that's what can happen with Shared fields in VB.NET.

Like I say, Context.Items can be just as useful as Session if you need
information to stick around during a Server.Transfer

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sun, 6 Mar 2005 13:58:41 -0700, "Wayne Wengert"
<wayneDONTWANTSPAM@.wengert.com> wrote:

>Scott;
>Thanks for the information. I think I am beginning to see my error here. The
>Common Class information exists once for my application and if User A sets a
>value in variable "X", any user asking for that variable will get that new
>value? This was my first attempt at using a common class and I think I went
>way overboard. I'll go back and change all use of the common class variables
>to Session objects instead and just use the common class for constant values
>like connection strings. Does that sound right?
>Wayne

Strange Behaviour

Hi,

I have developed a multi-frame web application with asp.net in c#. One frame
contains an embedded windows media 9 player for playing .wmv files. While
there is a file loaded in the player the other frames do not reliably
refresh.

Specifivally, if I try to refresh a page where I have overridden the Render
method, IE will stall. My attempts to debug this seem to indicate that this
stalling occurs before any code is excecuted. Refreshing the player frame
allows the stalled frame to load properly. When no file is open in the
player frame, everything works fine. This does not occur for asp.net pages
that do not override the render method, or simple html pages.

The page that causes this problem performs a SQL select in its render
method. It seems that this does not occur if there is no select in Render.

I have no idea what could be causing this. Any ideas would be greatly
appreciated.

thanks,

Grace SainsburyHi

Perhaps because the file in the player is still loading?
I did a test and no problems: http://213.190.104.211/

P.S Low bandwidth so it can take time to load...

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
==============================
"Grace Sainsbury" <grace@.multimediatranscripts.com> wrote in message
news:jjtrc.173$Nb4.7551@.news20.bellglobal.com...
> Hi,
> I have developed a multi-frame web application with asp.net in c#. One
> frame
> contains an embedded windows media 9 player for playing .wmv files. While
> there is a file loaded in the player the other frames do not reliably
> refresh.
> Specifivally, if I try to refresh a page where I have overridden the
> Render
> method, IE will stall. My attempts to debug this seem to indicate that
> this
> stalling occurs before any code is excecuted. Refreshing the player frame
> allows the stalled frame to load properly. When no file is open in the
> player frame, everything works fine. This does not occur for asp.net pages
> that do not override the render method, or simple html pages.
> The page that causes this problem performs a SQL select in its render
> method. It seems that this does not occur if there is no select in Render.
> I have no idea what could be causing this. Any ideas would be greatly
> appreciated.
> thanks,
> Grace Sainsbury
"Vidar Petursson" <thekingYoUKnOwWhatToDoHEREeh@.icysoft.com> wrote in message news:<uAh2$I5PEHA.2132@.TK2MSFTNGP11.phx.gbl>...
> Hi
> Perhaps because the file in the player is still loading?
> I did a test and no problems: http://213.190.104.211/
> P.S Low bandwidth so it can take time to load...

The problem occurs even when the entire file has been loaded -- i.e.
media pler is playing from its cache. With further experimentation, I
noticed that changing the focus away from IE, then returning causes
the refresh to complete.

thaks,

grace
Grace,

In my opinion I would try to duplicate the issue on another machine. This would eliminate your video and or system as a contributing factor. Is this for Internet Explorer and if so which version are you using? I'm pretty certain that the code running on the server is irrelevant unless the frame is hung up while processing that frame.

Good Luck!

-Calvin Luttrell
ProjectThunder.com

> I have developed a multi-frame web application with asp.net in c#. One frame
> contains an embedded windows media 9 player for playing .wmv files. While
> there is a file loaded in the player the other frames do not reliably
> refresh.
>
> Specifivally, if I try to refresh a page where I have overridden the Render
> method, IE will stall. My attempts to debug this seem to indicate that this
> stalling occurs before any code is excecuted. Refreshing the player frame
> allows the stalled frame to load properly. When no file is open in the
> player frame, everything works fine. This does not occur for asp.net pages
> that do not override the render method, or simple html pages.
>
> The page that causes this problem performs a SQL select in its render
> method. It seems that this does not occur if there is no select in Render.
>
> I have no idea what could be causing this. Any ideas would be greatly
> appreciated.

Strange behaviour in Production environnement

Hello experts,

I have the following peice of code in my Global.asax

void Application_Error(object sender, EventArgs e)

{

//get reference to the source of the exception chain

Log log = new Log();

Exception ex = Server.GetLastError();

log.AddLogEntry(Request, ex);

log.SaveData();

Response.Redirect("~/Error.aspx");

}

This code works well on my test server Win2k3 , IIS 6. It write to my
erro.log text file and displays Error.aspx as expected.

In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
last modified date) but the expection is not written to the file. Neither is
Error.aspx displayed. Can someone tell were i should be looking?

Many thanks in advance .

SHi,

Does asp.net process has write /modify permission on the folder/file that
you are attemting to write? I would also use:
Server.ClearError(); before redirecting.

Regards

Med

"Smith" <Smith@.pricateemail.comwrote in message
news:%23yjQVIQMIHA.5224@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>
Hello experts,
>
I have the following peice of code in my Global.asax
>
void Application_Error(object sender, EventArgs e)
>
{
>
//get reference to the source of the exception chain
>
Log log = new Log();
>
Exception ex = Server.GetLastError();
>
log.AddLogEntry(Request, ex);
>
log.SaveData();
>
Response.Redirect("~/Error.aspx");
>
>
>
>
>
>
}
>
>
>
This code works well on my test server Win2k3 , IIS 6. It write to my
erro.log text file and displays Error.aspx as expected.
>
>
>
In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
last modified date) but the expection is not written to the file. Neither
is Error.aspx displayed. Can someone tell were i should be looking?
>
>
>
>
>
Many thanks in advance .
>
S
>
>


"Med" <nospam@.nowhere.nowherewrote in message
news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

Hi,
>
Does asp.net process has write /modify permission on the folder/file that
you are attemting to write? I would also use:
Server.ClearError(); before redirecting.
>


The user asp.net process is running under har full permission in the folder
where the code lives.Also note that the modified date of the error file
actually change according to the time error occured. It this was permission
problem, would it be allowed to actually open the file?
How does ServerClear() helps here?

Thanks
S
Hi,

Quote:

Originally Posted by

The user asp.net process is running under har full permission in the
folder where the code lives.


Does the log folder/file resides in this folder?

Actually Server.ClearError(); was irrelavant to your problem here, it was
just a suggestion as it prevents the error from continuing to the
Application_Error event handler.

Could you send the code for AddLogEntry(Request, ex)?

This is how I do it:

<%@. Import Namespace = "System.IO" %>
<%@. Import Namespace = "System.Diagnostics" %>

void Application_Error(object sender, EventArgs e)
{
//Only redirect to error page if in Release mode.
#if DEBUG
{
//Show error details
}
#else
{
try
{
LogError(Server.GetLastError().GetBaseException()) ;
Server.ClearError();
}
catch
{
//Do something....
}

//Redirect to error.aspx page
Response.Redirect("error.aspx");
}
#endif
}

private void LogError(Exception objError)
{

try
{
string sLogFilePathAndName = String.Format(@."{0}{1} {2}.log",
Server.MapPath("~/Logs/"), DateTime.Now.ToLongDateString(),
DateTime.Now.DayOfWeek);
using (StreamWriter sw = File.AppendText(sLogFilePathAndName))
{
sw.WriteLine(Environment.NewLine);
sw.WriteLine(String.Format("Error Caught in Application on
{0} {1} @. {2}", DateTime.Now.DayOfWeek, DateTime.Now.ToLongDateString(),
DateTime.Now.ToLongTimeString()));
sw.WriteLine(String.Format("IP Address: {0}",
Request.ServerVariables["REMOTE_ADDR"].ToString()));
sw.WriteLine(String.Format("Platform: {0}",
Request.Browser.Platform));
sw.WriteLine(String.Format("Browser: {0}",
Request.Browser.Type));
sw.WriteLine(String.Format("Error in: {0}",
Request.Url.ToString()));
sw.WriteLine(String.Format("Error Message: {0}",
objError.Message.ToString()));
sw.WriteLine("Stack Trace:");
sw.WriteLine(objError.StackTrace.ToString());
sw.WriteLine(Environment.NewLine);
sw.WriteLine("--------------------------");
sw.Close();
}
}
catch
{
//Do something....
}
}

You may also want to look at:
http://support.microsoft.com/defaul...kb;en-us;306355
Hope it helps

Med

"Smith" <Smith@.pricateemail.comwrote in message
news:e5iA$HRMIHA.1208@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

>
"Med" <nospam@.nowhere.nowherewrote in message
news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...

Quote:

Originally Posted by

>Hi,
>>
>Does asp.net process has write /modify permission on the folder/file that
>you are attemting to write? I would also use:
>Server.ClearError(); before redirecting.
>>


>
The user asp.net process is running under har full permission in the
folder where the code lives.Also note that the modified date of the error
file actually change according to the time error occured. It this was
permission problem, would it be allowed to actually open the file?
How does ServerClear() helps here?
>
Thanks
S
>


http://support.microsoft.com/kb/890960

Strange behaviour in Production environnement

Hello experts,
I have the following peice of code in my Global.asax
void Application_Error(object sender, EventArgs e)
{
//get reference to the source of the exception chain
Log log = new Log();
Exception ex = Server.GetLastError();
log.AddLogEntry(Request, ex);
log.SaveData();
Response.Redirect("~/Error.aspx");
}
This code works well on my test server Win2k3 , IIS 6. It write to my
erro.log text file and displays Error.aspx as expected.
In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
last modified date) but the expection is not written to the file. Neither is
Error.aspx displayed. Can someone tell were i should be looking?
Many thanks in advance .
SHi,
Does asp.net process has write /modify permission on the folder/file that
you are attemting to write? I would also use:
Server.ClearError(); before redirecting.
Regards
Med
"Smith" <Smith@.pricateemail.com> wrote in message
news:%23yjQVIQMIHA.5224@.TK2MSFTNGP02.phx.gbl...
> Hello experts,
> I have the following peice of code in my Global.asax
> void Application_Error(object sender, EventArgs e)
> {
> //get reference to the source of the exception chain
> Log log = new Log();
> Exception ex = Server.GetLastError();
> log.AddLogEntry(Request, ex);
> log.SaveData();
> Response.Redirect("~/Error.aspx");
>
>
>
> }
>
> This code works well on my test server Win2k3 , IIS 6. It write to my
> erro.log text file and displays Error.aspx as expected.
>
> In Production( Win2k3 , IIS 6) , it open the file error.log(Can be seen on
> last modified date) but the expection is not written to the file. Neither
> is Error.aspx displayed. Can someone tell were i should be looking?
>
>
> Many thanks in advance .
> S
>
"Med" <nospam@.nowhere.nowhere> wrote in message
news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...
> Hi,
> Does asp.net process has write /modify permission on the folder/file that
> you are attemting to write? I would also use:
> Server.ClearError(); before redirecting.
>
The user asp.net process is running under har full permission in the folder
where the code lives.Also note that the modified date of the error file
actually change according to the time error occured. It this was permission
problem, would it be allowed to actually open the file?
How does ServerClear() helps here?
Thanks
S
Hi,

> The user asp.net process is running under har full permission in the
> folder where the code lives.
Does the log folder/file resides in this folder?
Actually Server.ClearError(); was irrelavant to your problem here, it was
just a suggestion as it prevents the error from continuing to the
Application_Error event handler.
Could you send the code for AddLogEntry(Request, ex)?
This is how I do it:
<%@. Import Namespace = "System.IO" %>
<%@. Import Namespace = "System.Diagnostics" %>
void Application_Error(object sender, EventArgs e)
{
//Only redirect to error page if in Release mode.
#if DEBUG
{
//Show error details
}
#else
{
try
{
LogError(Server.GetLastError().GetBaseException());
Server.ClearError();
}
catch
{
//Do something....
}
//Redirect to error.aspx page
Response.Redirect("error.aspx");
}
#endif
}
private void LogError(Exception objError)
{
try
{
string sLogFilePathAndName = String.Format(@."{0}{1} {2}.log",
Server.MapPath("~/Logs/"), DateTime.Now.ToLongDateString(),
DateTime.Now.DayOfW);
using (StreamWriter sw = File.AppendText(sLogFilePathAndName))
{
sw.WriteLine(Environment.NewLine);
sw.WriteLine(String.Format("Error Caught in Application on
{0} {1} @. {2}", DateTime.Now.DayOfW, DateTime.Now.ToLongDateString(),
DateTime.Now.ToLongTimeString()));
sw.WriteLine(String.Format("IP Address: {0}",
Request.ServerVariables["REMOTE_ADDR"].ToString()));
sw.WriteLine(String.Format("Platform: {0}",
Request.Browser.Platform));
sw.WriteLine(String.Format("Browser: {0}",
Request.Browser.Type));
sw.WriteLine(String.Format("Error in: {0}",
Request.Url.ToString()));
sw.WriteLine(String.Format("Error Message: {0}",
objError.Message.ToString()));
sw.WriteLine("Stack Trace:");
sw.WriteLine(objError.StackTrace.ToString());
sw.WriteLine(Environment.NewLine);
sw.WriteLine("---
--");
sw.Close();
}
}
catch
{
//Do something....
}
}
You may also want to look at:
http://support.microsoft.com/defaul...kb;en-us;306355
Hope it helps
Med
"Smith" <Smith@.pricateemail.com> wrote in message
news:e5iA$HRMIHA.1208@.TK2MSFTNGP05.phx.gbl...
> "Med" <nospam@.nowhere.nowhere> wrote in message
> news:%236KXucQMIHA.4228@.TK2MSFTNGP02.phx.gbl...
> The user asp.net process is running under har full permission in the
> folder where the code lives.Also note that the modified date of the error
> file actually change according to the time error occured. It this was
> permission problem, would it be allowed to actually open the file?
> How does ServerClear() helps here?
> Thanks
> S
>
I use the same log class as in the project :
http://www.asp.net/downloads/starter-kits/my-web-pages/
// ========================================
==================================
=====================
//
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See
http://www.microsoft.com/resources/...br />
es.mspx.
// All other rights reserved.
//
// ========================================
==================================
=====================
using System;
using System.Web;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace MyWebPagesStarterKit
{
/// <summary>
/// Utility for writing error messages to a Logfile
/// </summary>
[Serializable]
public class Log : Persistable<Log.LogData>
{
/// <summary>
/// Load Log File from App_Data
/// </summary>
public Log()
{
try
{
LoadData();
}
catch { }
}
/// <summary>
/// List of all Log-Entries in the Logfile
/// </summary>
public List<LogData.LogEntry> Entries
{
get { return _data.LogEntries; }
}
/// <summary>
/// Adding a new Log-Entry to the LogData
/// </summary>
/// <param name="Created"></param>
/// <param name="PageTitle"></param>
public void AddLogEntry(HttpRequest httpRequest, Exception ex)
{
LogData.LogEntry entry = new LogData.LogEntry();
//PageTitle
entry.PageTitle = httpRequest.Url.AbsolutePath;
//Date
entry.Created = DateTime.Now.ToLongDateString() + " " +
DateTime.Now.ToLongTimeString();
//Error
entry.Error = ex.ToString();
//HTTP-Values
foreach (string key in httpRequest.ServerVariables)
{
string value = httpRequest.ServerVariables[key];
if (value != string.Empty)
{
if (key == "ALL_HTTP" || key == "ALL_RAW")
value = value.Replace(System.Environment.NewLine, ", ");
entry.ServerVariables.Add(key + ": " + value);
}
}
/ ========================================
===================================
====================
//
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See
http://www.microsoft.com/resources/...br />
es.mspx.
// All other rights reserved.
//
// ========================================
==================================
=====================
using System;
using System.Web;
using System.IO;
using System.Xml.Serialization;
using System.Web.Caching;
namespace MyWebPagesStarterKit
{
/// <summary>
/// Generic class for a perssitable object. Encapsulates the logic to
load/save data from/to the filesystem. To speed up the acces, caching is
used.
/// </summary>
/// <typeparam name="T">class or struct with all the data-fields that must
be persisted</typeparam>
public abstract class Persistable<T>
{
private String _path;
protected T _data;
/// <summary>
/// Creates a instance of Persistable. Also creates a instance of T
/// </summary>
public Persistable()
{
_data = (T)Activator.CreateInstance(typeof(T));
}
/// <summary>
/// Loads the data from the filesystem. For deserialization a XmlSeralizer
is used.
/// </summary>
protected void LoadData()
{
_path = HttpContext.Current.Server.MapPath(GetDataFilename());
lock (_path)
{
//first check, if the object is maybe already in the cache
object o = HttpContext.Current.Cache[_path];
if (o != null)
{
_data = (T)o;
}
else
{
//if nothing was found in the cache, the data must be loaded from the disk
//load and deserialize the data from the filesystem
using (FileStream reader = File.Open(_path, FileMode.Open, FileAccess.Read,
FileShare.ReadWrite))
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
_data = (T)serializer.Deserialize(reader);
}
HttpContext.Current.Cache.Insert(_path, _data);
}
}
}
/// <summary>
/// Persists the data back to the filesystem
/// </summary>
public void SaveData()
{
_path = HttpContext.Current.Server.MapPath(GetDataFilename());
lock (_path)
{
//insert the data into the cache
HttpContext.Current.Cache.Insert(_path, _data, null, DateTime.MaxValue,
TimeSpan.FromHours(1), CacheItemPriority.Normal, null);
//if the given path does not exist yet, create it
if (!Directory.Exists(Path.GetDirectoryName(_path)))
Directory.CreateDirectory(Path.GetDirectoryName(_path));
//serialize and store the data to the filesystem
using (FileStream writer = File.Create(_path))
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.Serialize(writer, _data);
}
}
}
//Deletes the data from the cache and filesystem
public virtual bool Delete()
{
bool success = true;
if (File.Exists(_path))
{
lock (_path)
{
try
{
File.Delete(_path);
HttpContext.Current.Cache.Remove(_path);
}
catch { success = false; }
}
}
return success;
}
protected abstract string GetDataFilename();
}
}
Cheers
S

Strange behaviour of a dropdown list (again!)

I am steadily building up a full asp,net-based Web application.

I have a page within this application which has dropdownlist, data-bound to a query against the underlying database.

When I go there via the 'Interlink Button'on my home page, it fails, saying that the 'SelectCommand' has not ben activated.

However, when I go to it directly by selecting its URL in MSIE, it operates perfectly.

What is causing this anomaly?Looks like a problem with a DataAdapter somewhere, are you binding this dropdownlist with a dataset? Nothing is stopping you from doing this, but depending on the situation, it may be a little overkill. Have you tried just using a datareader?
There was a problem with file names, which I hadn't picked up.

It's working perfectly now.

Strange behaviour of Dropdownlists..

Hi All,
We have an application page that has several dropdownlists on it. Data enter
ed by the user is extracted from these dropdownlists is being stored in a MS
SQL database.
The problem is that the page works fine 99% of the time. However, there have
been cases where the selection on all dropdownlists has been reset to the f
irst item on the list. We have not been able to reproduce this error on our
development environment, bu
t the error continues to occur, albeit rarely.
Any inputs on this matter is greatly appreciated.
Thanks and Regards,
VamshiThank you for your response, Bruce.
However, I do not think that this error has anything to do with the use of t
he keyboard for input. What actually happens is that *all* dropdowns are bei
ng reinitialized to the first element on the list.
Just to be sure, I did try messing with the keyboard when the page was being
posted back, but was still unable to reproduce the error. Let me know if I'
m missing something.
Thanks and Regards,
Vamshi
-- bruce barker wrote: --
if any of the dropdowns are set for postback, you will have trouble if the
user uses the keyboard for entry (uparrow, drownarrow). you need to add
client code to disable the dropdown until the postback has completed.
-- bruce (sqlwork.com)
"Vamshi" <vamshi.ponnapalli@.analog.com> wrote in message
news:A4E6F089-8F9D-464A-B4CD-C5DB7D066B00@.microsoft.com...
> Hi All,
entered by the user is extracted from these dropdownlists is being stored in
a MS SQL database.
have been cases where the selection on all dropdownlists has been reset to
the first item on the list. We have not been able to reproduce this error on
our development environment, but the error continues to occur, albeit
rarely.
> Vamshi

Strange behaviour of Integers and Strings ?

If I am declaring a variable as integer ( int intcv_id = 0;) at the top of my page, so that i can access the value in all the methods thats my idea.

if(!IsPostBack)
{
BindData();
}

In one of my methods e.g. BindData() , I have changed the value of variable (e.g.intcv_id =Convert.ToInt32(Request.QueryString["id"]), incv_id is working properly in the BindData() method but when I am trying access the intcv_id value in some other methods, its just giving the initial value 0. I know that I can use Sessions to get over this problem, but I just want to know is there any other way out, rather than using sessions/viewstate.

Why is the integer behaving like that ? Integer is a Value-type isn't, it directly stores the value in the memory rather than its reference. Then why can't i access the stored memory value?

Its same with the strings i couldn't access the string value other than in its method , though I declare it globally. why are the value types and reference types behaving like this ?

Can anybody tell me whats happening inside please, these are basic doubts I am having though I am coding since a while

Thanks in Advance

When are you calling BindData relative to your referencing intcv_id elsewhere?

Asp.net is stateless, unless you store the value in ViewState/Session the integer variable will loose its value on postback.

I suggest create a property, each time you need the Id from the query string get it from the property.

public string Id

{

get { return Convert.ToInt32(Request.QueryString["id"]); }

}

Hope this answers your question.


Asp.net is stateless, unless you store the value in ViewState/Session the integer variable will loose its value on postback.

I suggest create a property, each time you need the Id from the query string get it from the property.

public string Id

{

get { return Convert.ToInt32(Request.QueryString["id"]); }

}

Hope this answers your question.


This is just a part of code i have edited it for readability, hope it makes sense, Thanks for your time
public partialclass viewcv : System.Web.UI.Page{SqlConnection objConn =new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DSN"]);SqlCommand objcmd;SqlDataReader objRdr;int intcv_id = 0;string js_id ="";protected void Page_Load(object sender, System.EventArgs e){if(!IsPostBack){BindData();}}private void BindData(){if(Convert.ToString(Request.QueryString["id"])!=null){ objcmd =new SqlCommand("SelectCreateCVDetails", objConn); objcmd.CommandType = CommandType.StoredProcedure; objcmd.Parameters.Add("@.cv_id", Request.QueryString["id"]); objConn.Open(); objRdr= objcmd.ExecuteReader(); objRdr.Read(); js_id = Convert.ToString(objRdr["JS_ID"]); objRdr.Close(); intcv_id = Convert.ToInt32(Request.QueryString["id"]); }}protected void lbcv_Click(object sender, EventArgs e) { Response.Write(js_id); // here if i test its giving null which is suppose to be 29 Response.Write(intcv_id); // here its suppose to be 17 but its 0 } }
 
 

Based on this sample it appears that you need to call DataBind every time (remove the PostBack condition). The Click event can only occur during a PostBack and you're only setting the values during the initial load.

Thank you very much guys for your help.

Both the property method and by removing the !IsPostBack in the Page_Load are working great.

So, as its storing the values initially but not during the postback and as the webpages are stateless we need to store them on every Page_Load , hope I am right in my deduction.

Thank you very much guys for your help and time


There are ways to store them, but it's usually more appropriate to only load when needed and if needed on every page instantiation then in Page_Load.

Strange behaviour with formauthentication and breakpoints

Hi there,
I 've an .aspx page which uses formsauthentication.
The formsauthentication works fine however. When I insert breakpoints
in the code which does the actual authentication, for example the
loginbutton click event, the breakpoints are ignored.
Now the most weird part comes:
Every sixth time I click the login button, the breakpoint work.

Does anyone have a clue what causes this?T-Bone wrote:
> Hi there,
> I 've an .aspx page which uses formsauthentication.
> The formsauthentication works fine however. When I insert breakpoints
> in the code which does the actual authentication, for example the
> loginbutton click event, the breakpoints are ignored.
> Now the most weird part comes:
> Every sixth time I click the login button, the breakpoint work.
> Does anyone have a clue what causes this?

Hi there T-Bone,

Sorry to say, but I dont have a clue. I experience also some weird
things when using Forms Authen. To me it seams that Forms Authen only
works if keep strict to the implementing that MS shows, as soon as you
start make changes it start behaving absolutely crazy.

Of course it could be that I dont understand the process well enough,
but dont u think that it is often like that when developing with MS. It
is like a surprise to actually see the results from time to time. You
dont know what to expect.

I have another weird problem, where I get (sometimes) redirected to the
wrong page (a page that doesnt exist of course).

If anyone out there could explain why these things happen I would be
much obliged.

rgds SparrowHawk

--

+================================================= =====================+
| SparrowHawk The Magician |
| |
| |
| |
| |
+================================================= =====================+
| e-mail: sparvhok[NOSPAM]hotmail.com |
+================================================= =====================+
To send me an email, replace the [NOSPAM] tag with @. sign.

Strange behaviour with formauthentication and breakpoints

Hi there,
I 've an .aspx page which uses formsauthentication.
The formsauthentication works fine however. When I insert breakpoints
in the code which does the actual authentication, for example the
loginbutton click event, the breakpoints are ignored.
Now the most weird part comes:
Every sixth time I click the login button, the breakpoint work.
Does anyone have a clue what causes this?T-Bone wrote:
> Hi there,
> I 've an .aspx page which uses formsauthentication.
> The formsauthentication works fine however. When I insert breakpoints
> in the code which does the actual authentication, for example the
> loginbutton click event, the breakpoints are ignored.
> Now the most weird part comes:
> Every sixth time I click the login button, the breakpoint work.
> Does anyone have a clue what causes this?
Hi there T-Bone,
Sorry to say, but I dont have a clue. I experience also some weird
things when using Forms Authen. To me it seams that Forms Authen only
works if keep strict to the implementing that MS shows, as soon as you
start make changes it start behaving absolutely crazy.
Of course it could be that I dont understand the process well enough,
but dont u think that it is often like that when developing with MS. It
is like a surprise to actually see the results from time to time. You
dont know what to expect.
I have another weird problem, where I get (sometimes) redirected to the
wrong page (a page that doesnt exist of course).
If anyone out there could explain why these things happen I would be
much obliged.
rgds SparrowHawk
+=======================================
===============================+
| SparrowHawk The Magician |
| |
| |
| |
| |
+=======================================
===============================+
| e-mail: sparvhok[NOSPAM]hotmail.com |
+=======================================
===============================+
To send me an email, replace the [NOSPAM] tag with @. sign.

Strange bugg with asp.net in Visual Studio

Hi,
I would appreciates some hints or help regarding a strange behaviour in
visual studio dotnet when using asp.net. I'm working with authentication
and somewhere in the process the framework goes nuts. Let me explain the
behaviour for you.
First you have a register page in the root of your project. Next you
have a folder named MemberPages and in this folder a login.aspx page.
And then you have welcome.aspx page.
You have a web.config and set restricion for anonymous users that
redirect to the login page.
If you compile and run the project you get the following error:
Could not load type 'GrundSys01.MemberPages.login'.
Ok and then you remove the login.aspx and rename the folder to MyPages
and then add a new login.aspx page and set it to start page.
Compile and run the project. Page displays fine.

Now why is that and what do I need to do?
I have tried to remove temporary files in framwork folder without
success.

I would appreciate if you could spend a little time to help me on this.

Regards
Andla

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Hi Andla,
It looks like a namespace problem.Check your project
properties and the inherits property of the page
directive on your login page.

Regards
-Narayana
>--Original Message--
>Hi,
>I would appreciates some hints or help regarding a
strange behaviour in
>visual studio dotnet when using asp.net. I'm working
with authentication
>and somewhere in the process the framework goes nuts.
Let me explain the
>behaviour for you.
>First you have a register page in the root of your
project. Next you
>have a folder named MemberPages and in this folder a
login.aspx page.
>And then you have welcome.aspx page.
>You have a web.config and set restricion for anonymous
users that
>redirect to the login page.
>If you compile and run the project you get the following
error:
>Could not load type 'GrundSys01.MemberPages.login'.
>Ok and then you remove the login.aspx and rename the
folder to MyPages
>and then add a new login.aspx page and set it to start
page.
>Compile and run the project. Page displays fine.
>Now why is that and what do I need to do?
>I have tried to remove temporary files in framwork
folder without
>success.
>I would appreciate if you could spend a little time to
help me on this.
>Regards
>Andla
>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.
Thanks for your answer.
I have tested different namespace adjustment without any success. Also
I'm not sure how this can be a namespace problem because that it fails
only if the folder name is MemberPages. Any other name do fine. Also I
have made a search for 'MemberPages' string in the root because I
suspected that this laid hidden somewhere. Any file containing this
string was either changed or deleted and still the same problem appeared
again.
Maybe I should check the registry and remove any key containing this
string.
Don't really know what more I can do.

Regards
Andla

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Strange caching behaviour with ASP.net 2.0

Last month we upgraded our production server from .net 1.1 to 2.0. We have
seen some odd behaviour that we do not know how to fix.

It seems that Cache is reset or cleared. We have 2 or 3 global entries in
the the cache with the NotRemovable flag set. I have set up a callback that
writes an entry to the event log to see if the Cache is cleared. It appears
that it is. This happens (randomly) several times a day. I changed our global
entries to use Application state however this just seemed to amplify the
problem.

Could this be a bug with 2.0 or does a server setting need changing
somewhere (it is a windows 2003 server)?

I do not know if the cache is being reset, causing the application to crash,
or something is causing the application to crash, resulting in the cache
being reset (I have added the LegacyUnhandledExceptionPolicy enabled="true"
attribute to the web.config with no joy)

At the same time that an entry is written to say the cache has been cleared,
the performance monitor registers requests /second at 286,000,000

If anyone has experienced similar issues, can shed some light or point me in
the right direction it would be greatly appreciated.

Kind Regards,

Darrencheck the event log for asp.net recycle events. maybe you app is using too
much memeory. you should never count on a cache persistance, the fetch logic
should always handle cache empty case.

-- bruce (sqlwork.com)

"Darren Newton" <Darren Newton@.discussions.microsoft.com> wrote in message
news:2DD4A241-C2B7-44EE-9CF2-06B9BDC65B21@.microsoft.com...
> Last month we upgraded our production server from .net 1.1 to 2.0. We have
> seen some odd behaviour that we do not know how to fix.
> It seems that Cache is reset or cleared. We have 2 or 3 global entries in
> the the cache with the NotRemovable flag set. I have set up a callback
> that
> writes an entry to the event log to see if the Cache is cleared. It
> appears
> that it is. This happens (randomly) several times a day. I changed our
> global
> entries to use Application state however this just seemed to amplify the
> problem.
> Could this be a bug with 2.0 or does a server setting need changing
> somewhere (it is a windows 2003 server)?
> I do not know if the cache is being reset, causing the application to
> crash,
> or something is causing the application to crash, resulting in the cache
> being reset (I have added the LegacyUnhandledExceptionPolicy
> enabled="true"
> attribute to the web.config with no joy)
> At the same time that an entry is written to say the cache has been
> cleared,
> the performance monitor registers requests /second at 286,000,000
> If anyone has experienced similar issues, can shed some light or point me
> in
> the right direction it would be greatly appreciated.
> Kind Regards,
> Darren
Thanks for your reply.

The logic always checks if the cache item exists and repopulates if
necessary. The code worked fine in 1.1 and didn't change when we moved to
2.0. The cache doesn't appear to be repopulating - if an exception occurs the
details are e-mailed to us. The details we receive would suggest that the
cache is empty.

I have been looking through the event log but there is nothing to suggest
asp.net is being recycled.

"bruce barker (sqlwork.com)" wrote:

> check the event log for asp.net recycle events. maybe you app is using too
> much memeory. you should never count on a cache persistance, the fetch logic
> should always handle cache empty case.
> -- bruce (sqlwork.com)
> "Darren Newton" <Darren Newton@.discussions.microsoft.com> wrote in message
> news:2DD4A241-C2B7-44EE-9CF2-06B9BDC65B21@.microsoft.com...
> > Last month we upgraded our production server from .net 1.1 to 2.0. We have
> > seen some odd behaviour that we do not know how to fix.
> > It seems that Cache is reset or cleared. We have 2 or 3 global entries in
> > the the cache with the NotRemovable flag set. I have set up a callback
> > that
> > writes an entry to the event log to see if the Cache is cleared. It
> > appears
> > that it is. This happens (randomly) several times a day. I changed our
> > global
> > entries to use Application state however this just seemed to amplify the
> > problem.
> > Could this be a bug with 2.0 or does a server setting need changing
> > somewhere (it is a windows 2003 server)?
> > I do not know if the cache is being reset, causing the application to
> > crash,
> > or something is causing the application to crash, resulting in the cache
> > being reset (I have added the LegacyUnhandledExceptionPolicy
> > enabled="true"
> > attribute to the web.config with no joy)
> > At the same time that an entry is written to say the cache has been
> > cleared,
> > the performance monitor registers requests /second at 286,000,000
> > If anyone has experienced similar issues, can shed some light or point me
> > in
> > the right direction it would be greatly appreciated.
> > Kind Regards,
> > Darren
>

Strange caching behaviour with ASP.net 2.0

Last month we upgraded our production server from .net 1.1 to 2.0. We have
seen some odd behaviour that we do not know how to fix.
It seems that Cache is reset or cleared. We have 2 or 3 global entries in
the the cache with the NotRemovable flag set. I have set up a callback that
writes an entry to the event log to see if the Cache is cleared. It appears
that it is. This happens (randomly) several times a day. I changed our globa
l
entries to use Application state however this just seemed to amplify the
problem.
Could this be a bug with 2.0 or does a server setting need changing
somewhere (it is a windows 2003 server)?
I do not know if the cache is being reset, causing the application to crash,
or something is causing the application to crash, resulting in the cache
being reset (I have added the LegacyUnhandledExceptionPolicy enabled="true"
attribute to the web.config with no joy)
At the same time that an entry is written to say the cache has been cleared,
the performance monitor registers requests /second at 286,000,000
If anyone has experienced similar issues, can shed some light or point me in
the right direction it would be greatly appreciated.
Kind Regards,
Darrencheck the event log for asp.net recycle events. maybe you app is using too
much memeory. you should never count on a cache persistance, the fetch logic
should always handle cache empty case.
-- bruce (sqlwork.com)
"Darren Newton" <Darren Newton@.discussions.microsoft.com> wrote in message
news:2DD4A241-C2B7-44EE-9CF2-06B9BDC65B21@.microsoft.com...
> Last month we upgraded our production server from .net 1.1 to 2.0. We have
> seen some odd behaviour that we do not know how to fix.
> It seems that Cache is reset or cleared. We have 2 or 3 global entries in
> the the cache with the NotRemovable flag set. I have set up a callback
> that
> writes an entry to the event log to see if the Cache is cleared. It
> appears
> that it is. This happens (randomly) several times a day. I changed our
> global
> entries to use Application state however this just seemed to amplify the
> problem.
> Could this be a bug with 2.0 or does a server setting need changing
> somewhere (it is a windows 2003 server)?
> I do not know if the cache is being reset, causing the application to
> crash,
> or something is causing the application to crash, resulting in the cache
> being reset (I have added the LegacyUnhandledExceptionPolicy
> enabled="true"
> attribute to the web.config with no joy)
> At the same time that an entry is written to say the cache has been
> cleared,
> the performance monitor registers requests /second at 286,000,000
> If anyone has experienced similar issues, can shed some light or point me
> in
> the right direction it would be greatly appreciated.
> Kind Regards,
> Darren
>
Thanks for your reply.
The logic always checks if the cache item exists and repopulates if
necessary. The code worked fine in 1.1 and didn't change when we moved to
2.0. The cache doesn't appear to be repopulating - if an exception occurs th
e
details are e-mailed to us. The details we receive would suggest that the
cache is empty.
I have been looking through the event log but there is nothing to suggest
asp.net is being recycled.
"bruce barker (sqlwork.com)" wrote:

> check the event log for asp.net recycle events. maybe you app is using too
> much memeory. you should never count on a cache persistance, the fetch log
ic
> should always handle cache empty case.
> -- bruce (sqlwork.com)
> "Darren Newton" <Darren Newton@.discussions.microsoft.com> wrote in message
> news:2DD4A241-C2B7-44EE-9CF2-06B9BDC65B21@.microsoft.com...
>
>

Monday, March 26, 2012

Strange DataView Problem

Hello,

I need some clarification about a stange DataView behaviour I have noticed. I am developing a dynamic website that is binding data (from an Access db) to a datagrid. I use a cached dataset to save trips to the db, here is the code...

'populate the Cache Variable that stores the Web Content Dataset
Public Function PopulateWebContentDataset(Optional ByVal blnRepopulate As Boolean = False) As Boolean

Dim ds As New DataSet()

'check if cached dataset already exists
If Current.Cache("WebContent") Is Nothing = False Then
'the cached variable already exists
Return True
End If

'get the Web Content from the database
Dim cn As New OleDbConnection(AppSettings("cnStringWebContent"))
Dim da As New OleDbDataAdapter("SELECT * FROM tblWebContent", cn)

Try
'fill the Web Content dataset with records from the database
da.Fill(ds, "tblWebContent")
If ds.Tables("tblWebContent").Rows.Count > 0 Then
'add the dataset to the cache
Current.Cache.Insert("WebContent", ds, _
New System.Web.Caching.CacheDependency(AppSettings("dbPathWebContent")), _
DateTime.Now.AddDays(1), Current.Cache.NoSlidingExpiration, _
System.Web.Caching.CacheItemPriority.Normal, Nothing)
Return True
Else
'no records were found
Current.Cache.Remove("WebContent")
Current.Cache("WebContent") = Nothing
Return False
End If

Catch DefaultExc As Exception

Finally
cn.Dispose()
da.Dispose()
ds.Dispose()
End Try

End Function

Public Function BindPageContent(ByRef dgr As DataGrid, ByVal strPage As String, _
Optional ByVal blnRepopulate As Boolean = False) As Boolean
'check if the cache Web Content dataset already exists
If PopulateWebContentDataset(blnRepopulate) = False And blnRepopulate = False Then
'unable to get the information from the database
Return False
End If

Dim ds As DataSet
Dim dv As New DataView()

Try

ds = Current.Cache("WebContent")
'ds.Tables("tblWebContent").DefaultView.RowFilter = "Page=" & "'" & strPage & "'"
dv = ds.Tables("tblWebContent").DefaultView
dv.RowFilter = "Page=" & "'" & strPage & "'"
dgr.DataSource = dv
dgr.DataBind()

Catch DefaultExc As Exception

Finally
ds.Dispose()
dv.Dispose()
End Try

End Function

My question is, the above code works perfectly the first time the page loads but when I return to this specific page (which should be getting the cached dataset), nothing is displayed. I checked the dataset and it has the correct amount of rows, however, the dataview has a rowcount of 0 (when it previously had a rowcount of 1).

I have done the following to fix this problem, all of which have worked...
1. Instead of getting the dataset from the cache, I connected to the db on each page_load and repopulated the dataset
2. When I bind the datagrid using the dataset as the datasource instead of the dataview, it works...

(ds.tables("tblWebContent").defaultview.rowfilter="Page='" & strPage & "'")

3. When I take out dv.dispose, everything works as expected

I have many instances in my code where I use the exact same code as posted above and it doesn't seem like there is a problem with the DataView. Should I re-examine all my code and remove dataview.dispose()? Does anyone have any suggestions on why this may be happening?Indeed, you shouldn't dispose that object since it's needed when the page execution is done further to display the data on the web form. In fact, it's a strange problem for me too but I would never dispose the dataview... Remember, the dataset object is a disconnected object which doesn't need any connection whatsoever with the database.

Saturday, March 24, 2012

strange event postback behaviour in dynamically created usercontrol

hi,
i have an aspx page which dynamically loads a user control and adds it
to a placeholder. the control is recreated and added to the
placeholder for postbacks as well.
the user control contains a datagrid and some buttons and textboxes.
the button events fire correctly and execute their code. however, the
datagrid events fire a postback, and execute Page_load in the
usercontrol, but the Item_Command code is not executed. the code to
add events to the datagrid is in InitialiseComponent.

i have the datagrid binding in UserControl_PreRender, so that it is
bound between postbacks.

can anyone suggest why the postback is happening without the
ItemCommand event happening? i've verified this with VS debugging.

thanks
timHi Tim_Mac,

Welcome to ASP.NET newsgroup.
From your description, you've a UserControl which contains some button and
a DataGrid on it, the datagrid is subscribing some postback
events(ItemCommand). And in one of your asp.net page, you dynamically load
the usercontrol and add it on your page. However, you found the ItemCommand
of the datagrid(in usercontrol) always not fire, yes?

Based on my experience, such event handler not executing problem is likely
caused by the following things:
1. For dynamic loaded(created) controls, make sure we add them in the
Page_Init or Page_Load every time the page is requested(IsPostback or
not...).

2. For control's event handler, we also need to register them in Init or
Load event. Also, for template databound controls such as DataGrid or
DataList, we should avoid rebinding them with different datasource before
processing postback event since the event may depend on the original binded
datas.

As for your condition, since some other controls (such as button)'s event
handler execute correctly. I think the problem is likely within the
UserControl itself. Would you try registering your datagrid's ItemCommand
handler in the usercontrol's ascx template instead of programmatically
register in codebehind? Just like
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...
If you feel it convenient, I suggest you try build a simpler usercontrol
(contains a datagrid) so as to repro the problem and send it to me. Then I
can do some researchs on my side.

In addition, if you feel necessary, I can also generate a test page on my
side and let you have a compare to see whehter there are any difference.

Please feel free to let me know if you have any questions. 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.)
hi Steven,
thank you for your most helpful reply.
i have got it working now, and will attempt to explain how and why for
future reference.

my aspx page contaings the following in Page_Load:
Modules.SportsLadder ladder =
this.LoadControl("Modules/SportsLadder.ascx") as Modules.SportsLadder;
this.serverForm.Controls.Add(ladder);

the user control is loaded regardless of whether a postback has taken
place or not.
the user control then contains a call to if(!IsPostBack) BindGrid() in
the Page_Load.

when i would delete an item in the datagrid, the page would post back,
and Page_Load would fire, but the datagrid_itemcommand event would not
fire. the datagrid would disappear from the page.

i tried adding in a PreRender event for the usercontrol, and calling
BindGrid() there, and that kept the datagrid on screen after postbacks,
but the itemcommand event still didn't fire. what got it working was i
removed the if(!IsPostBack) from the Page_Load of the user control, so
then the datagrid is bound every time. i then had the problem of the
itemcommand event being called twice (what a surprise). the reason is
because it was set in the aspx page, as Steven suggested:
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...>
but it was also set in InitialiseComponent in code. i took it out of
the code, and let the aspx handler do it.

now it works perfectly. i didn't run into any problems re-binding the
datagrid in Page_Load, my methods were still able to identify the row
that was clicked and any of the controls in the cells.

thanks for your help.
tim

strange event postback behaviour in dynamically created usercontrol

hi,
i have an aspx page which dynamically loads a user control and adds it
to a placeholder. the control is recreated and added to the
placeholder for postbacks as well.
the user control contains a datagrid and some buttons and textboxes.
the button events fire correctly and execute their code. however, the
datagrid events fire a postback, and execute Page_load in the
usercontrol, but the Item_Command code is not executed. the code to
add events to the datagrid is in InitialiseComponent.
i have the datagrid binding in UserControl_PreRender, so that it is
bound between postbacks.
can anyone suggest why the postback is happening without the
ItemCommand event happening? i've verified this with VS debugging.
thanks
timHi Tim_Mac,
Welcome to ASP.NET newsgroup.
From your description, you've a UserControl which contains some button and
a DataGrid on it, the datagrid is subscribing some postback
events(ItemCommand). And in one of your asp.net page, you dynamically load
the usercontrol and add it on your page. However, you found the ItemCommand
of the datagrid(in usercontrol) always not fire, yes?
Based on my experience, such event handler not executing problem is likely
caused by the following things:
1. For dynamic loaded(created) controls, make sure we add them in the
Page_Init or Page_Load every time the page is requested(IsPostback or
not...).
2. For control's event handler, we also need to register them in Init or
Load event. Also, for template databound controls such as DataGrid or
DataList, we should avoid rebinding them with different datasource before
processing postback event since the event may depend on the original binded
datas.
As for your condition, since some other controls (such as button)'s event
handler execute correctly. I think the problem is likely within the
UserControl itself. Would you try registering your datagrid's ItemCommand
handler in the usercontrol's ascx template instead of programmatically
register in codebehind? Just like
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...>
If you feel it convenient, I suggest you try build a simpler usercontrol
(contains a datagrid) so as to repro the problem and send it to me. Then I
can do some researchs on my side.
In addition, if you feel necessary, I can also generate a test page on my
side and let you have a compare to see whehter there are any difference.
Please feel free to let me know if you have any questions. 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.)
hi Steven,
thank you for your most helpful reply.
i have got it working now, and will attempt to explain how and why for
future reference.
my aspx page contaings the following in Page_Load:
Modules.SportsLadder ladder =
this.LoadControl("Modules/SportsLadder.ascx") as Modules.SportsLadder;
this.serverForm.Controls.Add(ladder);
the user control is loaded regardless of whether a postback has taken
place or not.
the user control then contains a call to if(!IsPostBack) BindGrid() in
the Page_Load.
when i would delete an item in the datagrid, the page would post back,
and Page_Load would fire, but the datagrid_itemcommand event would not
fire. the datagrid would disappear from the page.
i tried adding in a PreRender event for the usercontrol, and calling
BindGrid() there, and that kept the datagrid on screen after postbacks,
but the itemcommand event still didn't fire. what got it working was i
removed the if(!IsPostBack) from the Page_Load of the user control, so
then the datagrid is bound every time. i then had the problem of the
itemcommand event being called twice (what a surprise). the reason is
because it was set in the aspx page, as Steven suggested:
<asp:datagrid ..... OnItemCommand="DataGrid_ItemCommand" ...>
but it was also set in InitialiseComponent in code. i took it out of
the code, and let the aspx handler do it.
now it works perfectly. i didn't run into any problems re-binding the
datagrid in Page_Load, my methods were still able to identify the row
that was clicked and any of the controls in the cells.
thanks for your help.
tim
Hi Tim_Mac,
Thanks a lot for your detailed response. I'm glat that you've got greate
progress on this issue. Though you've got it worked currently, I'm still
abit confusing about your detailed page and usercontrol's code logic. Based
on my understanding, as long as your UserControl is added into the page's
control collection everytime( and has a fixed it assigned to it). We don't
need to bind data to the datagrid(in the usercontrol) everytime, just in
If(! IsPostback) ) or in a postback event is ok. And the ItemCommand can
also fire correctly.
I've attached a sample page/usercontrol I used to test. You can have a test
on your side if you have interesting.
Hope helps. If there is anything else unclear, please feel free to post
here. 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.)