Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > What's wrong with this code?

Reply
Thread Tools

What's wrong with this code?

 
 
Allixria
Guest
Posts: n/a
 
      10-18-2004
Hi all... I need help in there :

In the Page_Load :
///////////////////////////////////////
If Not IsPostBack Then
If Not (Session("CurrentTextBox1") Is Nothing) Then
TextBox1 = Session("CurrentTextBox1") <--- ***
End If
Else
TextBox1.text = "Hello World!"
Session("CurrentTextBox1") = TextBox1
End If
///////////////////////////////////////

Later in some code, there is a Redirect to this page adding a param
value so this page is recalled, and...

*** : TextBox1 is returned as an object, ok, but his .text value is
empty....
What to do with that? Really I think I miss something here!!

TIA,
Ally

 
Reply With Quote
 
 
 
 
Scott Mitchell [MVP]
Guest
Posts: n/a
 
      10-18-2004
Allixria wrote:
> In the Page_Load :
> ///////////////////////////////////////
> If Not IsPostBack Then
> If Not (Session("CurrentTextBox1") Is Nothing) Then
> TextBox1 = Session("CurrentTextBox1") <--- ***
> End If
> Else
> TextBox1.text = "Hello World!"
> Session("CurrentTextBox1") = TextBox1
> End If
> ///////////////////////////////////////
>
> Later in some code, there is a Redirect to this page adding a param
> value so this page is recalled, and...
>
> *** : TextBox1 is returned as an object, ok, but his .text value is
> empty....
> What to do with that? Really I think I miss something here!!


Why are you storing the TextBox object in Session? Why not just the
..Text property value, since that, it appears, is all you care about
persisting?


--

Scott Mitchell
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
Reply With Quote
 
 
 
 
Allixria
Guest
Posts: n/a
 
      10-18-2004
Hi Scott

In fact, I wanted to simplify the problem.. I used a textbox and it
didn't work, but in fact I want to store a custom treeview object into
a session variable to be able to restore it's design and all of his
nodes..

Here's the code in the page_load :

If Not IsPostBack Then
If Not (Session("CurrentTreeView") Is Nothing) Then
oTree = CType(Session("CurrentTreeView"),
squishyWARE.WebComponents.squishyTREE.TreeView)
Else
PopulateTreeview(oTree)
Session("CurrentTreeView") = oTree
End If
Else
Session("CurrentTreeView") = oTree
End If

TIA

 
Reply With Quote
 
Allixria
Guest
Posts: n/a
 
      10-19-2004
Thanx anyway, I have solved my problem.

I used HttpContext.Current.Cache to cache my treeview object (that I
had to serialize too).

I had to remove and add again the control in the page :

Me.controls.remove(oTree)
Me.controls.add(oTree) because I was having 2 controls...

Below I added:
oTree = ctype(HttpContext.Current.Cache("oTree"),TreeView)
Does anyone knows why I had to remove the oTree control ?

 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      10-19-2004
you don't store controls in session, the behavior isn't guaranteed. In fact,
nested hierarchies of objects in the tree won't function correctly after
retrieving from session. that has been my experience.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Allixria" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Thanx anyway, I have solved my problem.
>
> I used HttpContext.Current.Cache to cache my treeview object (that I
> had to serialize too).
>
> I had to remove and add again the control in the page :
>
> Me.controls.remove(oTree)
> Me.controls.add(oTree) because I was having 2 controls...
>
> Below I added:
> oTree = ctype(HttpContext.Current.Cache("oTree"),TreeView)
> Does anyone knows why I had to remove the oTree control ?
>



 
Reply With Quote
 
Allixria
Guest
Posts: n/a
 
      10-19-2004
Thanx for the warning Alvin, and sorry everybody for the
"clearness-less" of my previous explanations! Maybe I was too tired,
bugging at this problem.

I often forget too that all of you have no idea of where I'm in, and I
forget to be more clear when explaining my problem...

For this tree control, I have to tell that even if this custom control
was great, it have some problems... I choose it because there was easy
access to storing keys, and to find them, unlike the MS one in the
WebControls package. I wanted too to be able to customize this treeview
(css styles for example). So I used this little "unsupported now"
control but it seems to do the job for now.

This control has only the job to send the node's key in querystring
when it is clicked, and then another control in the page has the job to
see if this querystring is empty or not to display properly his stuff.
The treeview has no behaviours more to do, than only one in fact (and
that was my problem ) : to keep your nodes opened and closed as you
were the last time the person clicked on it.

What I try to do : A Knowledge base articles ...

Thanx for your help!
p.s. This treeview was free and available at gotdotnet if anyone
wonders... made in C# by asills.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Have I bought wrong product? enquirer Wireless Networking 2 06-10-2005 10:59 PM
Zero Config keeps connecting to the wrong AP =?Utf-8?B?ZGdyaWZmaXRo?= Wireless Networking 2 03-04-2005 05:52 PM
Is XML Doc wrong or is Schema wrong? (or both) Matthew XML 7 01-07-2005 10:05 PM
wrong connection status Peter Welk Wireless Networking 0 12-22-2004 03:26 PM
XP SP2 Wrong IP on connection D Wells Wireless Networking 3 12-09-2004 03:35 AM



Advertisments