Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

i want to display data in a table on a asp.net web page.

 

i have done his using the old asp using a response.write("") in a loop to create the table rows.

 

what is the best way to do this in ASP.net?

without time nothing ever ends
Posted

I can now use the table form. i just havent had a chance to note it in this call yet.

 

i have managed to get the table to load when the page is created. that is not a problem.

 

within that table that i dynamically create i can have one of the cell values set as a hyperlink that can again be dynamically created so that it contains a query string. when this is then clicked on the next page that i need to open can wonder off with the query string value and get the data from my database.

 

the only problem i have now is the one i posted back on

 

http://www.xtremedotnettalk.com/t76875.html

 

i need to be able to get a complex string from another page, and using the query string method is not sufficient because it is possible to enter anything (including anything like ? and & which may cause a problem)

 

 

Is is possible to lift information from one aspx page and import it into the load of the following aspx page?

 

 

this is something that i have posted before i know, but this time i really think that i am going to have to be able to send informaiton like the old ASP post method.

 

i just need to know how to do it.

 

you see i would have been able to type

 

request("the_variable_i_need")

 

and it would have pulled it across.

 

any thoughts??

without time nothing ever ends
  • Moderators
Posted

One way is this....

 

'page that contains the data (this class would be named SendingPage)

Public ReadOnly Property SomeString() As String
   Get
     Return SomeMemberVariable
   End Get
 End Property

 

'page that requests the data

Private otherPage As SendingPage '(the name of the previous page)


Private Sub Page_Load(....)
   If Not IsPostBack Then
      otherPage =  CType(Context.Handler, SendingPage)
   End If

'now you can use the value anywhere on this page....
 dim s as string = otherPage.SomeString

 End Sub

 

 

Any object can be passed using the above example.

Visit...Bassic Software
Posted

I have a problem with this. Basically it doesnt work when i try to do it.

 

I am not sure that this is the problem. If i am right, i just place this code within the page i am 'sending' the data from...it just goes within the code right?

 

'page that contains the data (this class would be named SendingPage)

Public ReadOnly Property SomeString() As String
   Get
     Return SomeMemberVariable
   End Get
 End Property

 

This code DOES seem to the be the problem though. I think it might just be the way that i am using it.

 

'page that requests the data

Private otherPage As SendingPage '(the name of the previous page)


Private Sub Page_Load(....)
   If Not IsPostBack Then
      otherPage =  CType(Context.Handler, SendingPage)
   End If

'now you can use the value anywhere on this page....
 dim s as string = otherPage.SomeString

 End Sub
 

 

 

 

Private otherPage As SendingPage '(the name of the previous page)

 

where does the above piece go within the page that i am opening (outside of any subs?)

 

when i run it the problem i have is to do with the cast. it says that it is an invalid cast?

 

anythoughts?

without time nothing ever ends
Posted

still no joy.

 

page1 code.

 

i have the code within the class. it is outside of any other functions, it is stand alone within the class.

 

page2 code.

 

i have the

 private otherpage as page1 

above the load of the page. it is not part of any sub but is within the class.

 

i have the other code

If Not IsPostBack Then
           otherPage = CType(Context.Handler, query)
       End If

 

within the load of page2.

 

when i compile the pages i do not get an error. when i run the page though i do get an error.

 

 

it says "Specified cast is not valid". this error occurs when i enter the page 2. and must be to do with the CType that i have there. this is the only cast that exists on the page.

 

robby / anyone have an example of this code working?

 

i dont know whats up with what i am doing. i cant see anything wrong.

without time nothing ever ends
Posted
Follow my example and it will work.

 

What's query? That should be the class name of the previous page.

 

query is the name of the class on the page (page1).

 

i have found another link. The code is very simliar as yours. This other code puts it in the HTML of the page though, not in the aspx.vb

 

should i put it in there?

without time nothing ever ends
Posted

ahblahdeehell...

 

I have solved the problem. I had to use server.transfer("pagename.aspx") for the movement between the pages!

 

i kept gettin that bloddy cast problem that means absolutely nothing when you know how to fix the problem!

 

you must use the above instead of using response.redirect("pagename.aspx")

 

i am sorry if this something that was obvious robby and to others.

 

thanks for you help with this one though, got there in the end.

 

Papa.

 

*****CLOSED*****

without time nothing ever ends

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...