Showing posts with label ispostback. Show all posts
Showing posts with label ispostback. Show all posts

Thursday, March 29, 2012

Session variable and postback question

Hello,
I have this web form where I have something like

--In pageload

If not ispostback then
session("drc") = ......
end if

and I intend to use this drc(datarowcollection) throughout a user session.

My problem is this: When a postback occurs because of say a buttonclick or radiobutton click then everything happens as I expect it to work. But when in the middle of a session I press the Refresh button of the browser (IE), then it goes into the code above i.e. page.postback = false. Because of this, I am facing a lot of difficulty. Is this something to do with the session variable. Is there another way in which I can store the datarowcollection so that I can use the same throughout the session.

_Please Help_. I would really appreciate it.

Thanks,
dotosuSo if it is NOT a postback you check for the existence of the session variable and if it does NOT exist you create what you need and then store it in there? Or you just assume that the session variable is not in there at all?
But my question is if say session.timeout = 20 and I go to this page in question and move around for 5 minutes, everything is working fine but then if I hit the Refresh button on the browser then it goes into If not page.ispostback statement. Now, it is not supposed to do this since it is not really bringing up the page for the first time, right?

Am I missing something here?

PLEASE HELP!!

Thanks, dotosu
Would anyone know why this might be happening. I would greatly appreciate help.

-dotosu
To the web server it is bringing up the page for the first time whether the session has timed out or not. This is if you do a refresh without first doing a postback.

I don't think I understand what your difficulty is here. Could you try to explain it another way and maybe I can offer more help?
I think I am sort of confused here. Please check my first post in this thread for an explanation of what my problem is. I don't think I can explain it any better but I sure need some help with this.

Now as far as I understand, we have such a sub

Sub Page_Load(...)
If Not IsPostback Then
'do something for situations when the page is first brought up
Else
' do something for situations when the page is brought up after first time
End If
End Sub
Do I not understand this correctly?

Thanks,
dotosu
Try this;

If Page.IsPostBack = False Then

'check if a session already exist
If Session("drc") = 0 Then
'set the session
Session("drc") = "yourinfo"
end if
</code
Hope this helps..
Sorry about my last oversight

Try this;


If Page.IsPostBack = False Then

'check if a session already exist
If Len(Session("drc")) = 0 Then
'set the session
Session("drc") = yourinfo
end if

Len is for the expression object (zero) as integer

Saturday, March 24, 2012

Session Variable update problem

I have two ASPX in my testproject :
1:
In the Page_load there is :
If Not Me.IsPostBack Then
Dim tfm
tfm = 30
Session("tfm") = tfm
Dim popupScript As String = "<script
language='javascript'>alert('Yes');</script>"
Page.RegisterStartupScript("PopupScript", popupScript)
End If
and there is the function that should change to value of tfm
Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rlist1.CheckedChanged
Dim tfm
tfm = Session("tfm")
tfm = 55
Session("tfm") = tfm
lblTotaal.Text = "gert" & Str(Session("tfm"))
End Sub
What happens : the lblTotaal will show me the 55 instead of the 30. But in
the next aspx the following returns the 30 again
If Not Me.IsPostBack Then
Dim tfm
tfm = Session("tfm")
Label1.Text = Str(tfm)
end if
PLEASE HELP ! What am I doing wrong,Gert:
This may be a ViewState issue, where the view state is changing the value of
the label to the old value. One suggestion would be to set the
EnableViewState property of the label to false.
David Lloyd
MCSD .NET
http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"gce" <gceng2@.hotmail.com> wrote in message
news:d5hhqu$7a1$1@.news1.zwoll1.ov.home.nl...
> I have two ASPX in my testproject :
> 1:
> In the Page_load there is :
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = 30
> Session("tfm") = tfm
> Dim popupScript As String = "<script
> language='javascript'>alert('Yes');</script>"
> Page.RegisterStartupScript("PopupScript", popupScript)
> End If
> and there is the function that should change to value of tfm
> Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles rlist1.CheckedChanged
> Dim tfm
> tfm = Session("tfm")
> tfm = 55
> Session("tfm") = tfm
> lblTotaal.Text = "gert" & Str(Session("tfm"))
> End Sub
>
> What happens : the lblTotaal will show me the 55 instead of the 30. But in
> the next aspx the following returns the 30 again
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = Session("tfm")
> Label1.Text = Str(tfm)
> end if
> PLEASE HELP ! What am I doing wrong,
>

Session Variable update problem

I have two ASPX in my testproject :

1:

In the Page_load there is :

If Not Me.IsPostBack Then
Dim tfm
tfm = 30
Session("tfm") = tfm
Dim popupScript As String = "<script
language='javascript'>alert('Yes');</script>"
Page.RegisterStartupScript("PopupScript", popupScript)
End If

and there is the function that should change to value of tfm

Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles rlist1.CheckedChanged
Dim tfm
tfm = Session("tfm")
tfm = 55
Session("tfm") = tfm
lblTotaal.Text = "gert" & Str(Session("tfm"))
End Sub

What happens : the lblTotaal will show me the 55 instead of the 30. But in
the next aspx the following returns the 30 again

If Not Me.IsPostBack Then
Dim tfm
tfm = Session("tfm")
Label1.Text = Str(tfm)
end if

PLEASE HELP ! What am I doing wrong,Gert:

This may be a ViewState issue, where the view state is changing the value of
the label to the old value. One suggestion would be to set the
EnableViewState property of the label to false.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.

"gce" <gceng2@.hotmail.com> wrote in message
news:d5hhqu$7a1$1@.news1.zwoll1.ov.home.nl...
> I have two ASPX in my testproject :
> 1:
> In the Page_load there is :
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = 30
> Session("tfm") = tfm
> Dim popupScript As String = "<script
> language='javascript'>alert('Yes');</script>"
> Page.RegisterStartupScript("PopupScript", popupScript)
> End If
> and there is the function that should change to value of tfm
> Private Sub rlist1_CheckedChanged(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles rlist1.CheckedChanged
> Dim tfm
> tfm = Session("tfm")
> tfm = 55
> Session("tfm") = tfm
> lblTotaal.Text = "gert" & Str(Session("tfm"))
> End Sub
>
> What happens : the lblTotaal will show me the 55 instead of the 30. But in
> the next aspx the following returns the 30 again
> If Not Me.IsPostBack Then
> Dim tfm
> tfm = Session("tfm")
> Label1.Text = Str(tfm)
> end if
> PLEASE HELP ! What am I doing wrong,