Click here to Skip to main content
15,914,395 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: plzz write a simple function on.......... Pin
rockford.boulderdash11-Jan-07 8:40
rockford.boulderdash11-Jan-07 8:40 
GeneralRe: plzz write a simple function on.......... Pin
Not Active11-Jan-07 8:42
mentorNot Active11-Jan-07 8:42 
GeneralRe: plzz write a simple function on.......... Pin
rockford.boulderdash11-Jan-07 8:47
rockford.boulderdash11-Jan-07 8:47 
GeneralRe: plzz write a simple function on.......... Pin
Not Active11-Jan-07 8:57
mentorNot Active11-Jan-07 8:57 
GeneralRe: plzz write a simple function on.......... Pin
_AK_11-Jan-07 17:18
_AK_11-Jan-07 17:18 
AnswerRe: plzz write a simple function on.......... Pin
saravanan0511-Jan-07 9:09
saravanan0511-Jan-07 9:09 
QuestionPaypal buynow control's IPN notify_url Pin
Nadia Monalisa11-Jan-07 5:12
Nadia Monalisa11-Jan-07 5:12 
Questionimages with sessions in asp Pin
ADY00711-Jan-07 4:27
ADY00711-Jan-07 4:27 
hi, can anyone help me on this problem thats occurring. I created a forum and its like this .. www.ivanandsimone.com/Query/Home.aspx. Now the problem is this, when i enter in the home.aspx 3 imagebuttons of 3 different items are shown above the page for instance (mobile, computer and book). When someone click on a picture it will take him in its (item description) of that item.

at that point everything works well but when a person clicks the back button of the windows explorer from the taskbar .. the pictures will ramins the same (mobile, computer and book) but the sessions will be overwrited by other numbers.

I am using Sessions to store every picture (the 3 pictures) ID number and then send that ID number to the Item.aspx page. The Item.aspx page will then see the ID and from the database it will search for the information about that ID that the user chosen.

Now the code is this:

This is for the Page_Load
If Request.QueryString("ItemID") <> "" Then<br />
            Session(ID) = Request.QueryString("ItemID")<br />
<br />
            Response.Redirect("Item.aspx")<br />
        End If<br />
<br />
        If Not IsPostBack Then<br />
            Try<br />
                odcConn = New OleDbConnection(strConn)<br />
                daMem = New OleDbDataAdapter("Select * From tblItems Order By ItemID Desc", odcConn)<br />
                dsMem.Clear()<br />
                daMem.Fill(dsMem, "tblItems")<br />
                dgItems.SelectedIndex = -1<br />
                dgItems.DataSource = dsMem.Tables("tblItems")<br />
                dgItems.DataBind()<br />
                odcConn.Close()<br />
                Session("Num1") = Nothing<br />
                Session("Num2") = Nothing<br />
                Session("Num3") = Nothing<br />
                FillCategories()<br />
            Catch ex As Exception<br />
                odcConn.Close()<br />
            End Try<br />
        End If<br />
<br />
        ChooseItems()<br />
    End Sub


So the sessions - Session("Num1") and the other 2 are the storeage that i told you. Now for the Image Picker of the ImageButtons I am using this code:

Private Sub ChooseItems()<br />
        Dim strImage As String<br />
        Dim strItem As String<br />
        Dim daItem As OleDbDataAdapter<br />
        Dim ds As New DataSet<br />
        Dim i As Integer = 0<br />
<br />
        Dim randNum As New Random<br />
        Dim intNum As Integer = randNum.Next(0, 22)<br />
<br />
        odcConn = New OleDbConnection(strConn)<br />
        daItem = New OleDbDataAdapter("SELECT * FROM tblItems", odcConn)<br />
        daItem.Fill(ds, "tblItems")<br />
<br />
        Try<br />
            strImage = ds.Tables("tblItems").Rows(intNum)("Image1")<br />
<br />
            imgItem1.ImageUrl = strImage<br />
<br />
            strItem = ds.Tables("tblItems").Rows(intNum)("Item")<br />
<br />
            lblItem1.Text = "Item:   " & strItem<br />
<br />
            If Session("Num1") = Nothing Then<br />
                Session("Num1") = ds.Tables("tblItems").Rows(intNum)("ItemID")<br />
            End If<br />
        Catch ex As Exception<br />
            odcConn.Close()<br />
            Exit Try<br />
        End Try<br />
<br />
        intNum = randNum.Next(0, 22)<br />
        daItem = New OleDbDataAdapter("SELECT * FROM tblItems", odcConn)<br />
        daItem.Fill(ds, "tblItems")<br />
<br />
        Try<br />
            strImage = ds.Tables("tblItems").Rows(intNum)("Image1")<br />
<br />
            imgItem2.ImageUrl = strImage<br />
<br />
<br />
            strItem = ds.Tables("tblItems").Rows(intNum)("Item")<br />
<br />
            lblItem2.Text = "Item:   " & strItem<br />
<br />
            If Session("Num2") = Nothing Then<br />
                Session("Num2") = ds.Tables("tblItems").Rows(intNum)("ItemID")<br />
            End If<br />
        Catch ex As Exception<br />
            odcConn.Close()<br />
            Exit Try<br />
        End Try<br />
<br />
        intNum = randNum.Next(0, 22)<br />
        daItem = New OleDbDataAdapter("SELECT * FROM tblItems", odcConn)<br />
        daItem.Fill(ds, "tblItems")<br />
<br />
        Try<br />
            strImage = ds.Tables("tblItems").Rows(intNum)("Image1")<br />
<br />
            imgItem3.ImageUrl = strImage<br />
<br />
            strItem = ds.Tables("tblItems").Rows(intNum)("Item")<br />
<br />
            lblItem3.Text = "Item:   " & strItem<br />
<br />
            If Session("Num3") = Nothing Then<br />
                Session("Num3") = ds.Tables("tblItems").Rows(intNum)("ItemID")<br />
            End If<br />
        Catch ex As Exception<br />
            odcConn.Close()<br />
            Exit Try<br />
        End Try<br />
<br />
        odcConn.Close()<br />
    End Sub


Can anyone help me in this problem Frown | :( because I got a big headache trying to fix this problem all night!

Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.

AnswerRe: images with sessions in asp Pin
Britney S. Morales11-Jan-07 11:48
Britney S. Morales11-Jan-07 11:48 
QuestionSSL Pin
DBNashville11-Jan-07 4:23
DBNashville11-Jan-07 4:23 
Questionasp.net validations Pin
P Bhasker11-Jan-07 3:42
P Bhasker11-Jan-07 3:42 
AnswerRe: asp.net validations Pin
_AK_11-Jan-07 3:45
_AK_11-Jan-07 3:45 
GeneralRe: asp.net validations Pin
P Bhasker11-Jan-07 3:52
P Bhasker11-Jan-07 3:52 
GeneralRe: asp.net validations Pin
sanaziuse11-Jan-07 4:07
sanaziuse11-Jan-07 4:07 
Questionhow to use application state and session state Pin
Rmesh11-Jan-07 2:41
Rmesh11-Jan-07 2:41 
AnswerRe: how to use application state and session state Pin
_AK_11-Jan-07 2:50
_AK_11-Jan-07 2:50 
AnswerRe: how to use application state and session state [modified] Pin
Skanless11-Jan-07 9:32
Skanless11-Jan-07 9:32 
QuestionCustomize the Calendar Control Pin
RX Maverick11-Jan-07 2:21
RX Maverick11-Jan-07 2:21 
AnswerRe: Customize the Calendar Control Pin
Mike Ellison11-Jan-07 3:52
Mike Ellison11-Jan-07 3:52 
GeneralRe: Customize the Calendar Control Pin
RX Maverick16-Jan-07 4:08
RX Maverick16-Jan-07 4:08 
GeneralRe: Customize the Calendar Control Pin
Mike Ellison16-Jan-07 7:19
Mike Ellison16-Jan-07 7:19 
QuestionDisplaying a Image from a MySQL db Pin
tmoney10111-Jan-07 1:24
tmoney10111-Jan-07 1:24 
AnswerRe: Displaying a Image from a MySQL db Pin
SICStus11-Jan-07 4:39
SICStus11-Jan-07 4:39 
GeneralRe: Displaying a Image from a MySQL db Pin
tmoney10111-Jan-07 11:21
tmoney10111-Jan-07 11:21 
GeneralRe: Displaying a Image from a MySQL db Pin
SICStus11-Jan-07 23:54
SICStus11-Jan-07 23:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.