Maintain viewstate

A

Abhilash

Hi,

I have the following requirement but i am not sure how to tackle it.

I have two sever controls called Editor1 and Editor2 that contains a
text box with enableview state = true.

Based on a url parameter "show=Editor1" or "show=Editor2" only one fo
the server controls is displayed to the user. The other is hidden.

I have provided two hyperlinks (Editor1 and Editor2) to switch between
the two (the difference is that it calls the same page with different
value for the "show" parameter)

I would like to type some text say "Editor1 text" into the textbox of
Editor1 and then switch to the other server control by clicking on the
hyperlink "Editor2". Then i type in the texbox of Editor2 text say
"Editor2 text". Now when i click on the hyperlink "Editor1" i want the
previous value to be shown. Similary now when i click on the hyperlink
"Editor2" i want the previous value to be shown.


How can i acheive this?

Regards,
Abhilash
 
G

garethdjames

Instead of using a URL param (show = ) use the post back mechanism,

Use A hyperlink server control for each editor you want to show, i.e.
Link1 when clicked shows editor1 and hides editor2 (opposite for the
other one)

use a event handler to set the visibility of each editor,

This way viewstate will cater for the text entered into the editors
 
G

Guest

Instead of passing QueryString parameter between 2 pages, place both controls
on the one page and add 2 LinkButtons that toggle their visibility according
to the link pressed. For example:

<asp:LinkButton CommandName="ShowEditor1" Runat="server" ID="Linkbutton1"
Text="show Editor1"></asp:LinkButton>
<asp:LinkButton CommandName="ShowEditor2" Runat="server" ID="Linkbutton2"
Text="show Editor2"></asp:LinkButton>

and in the CodeBehind file add their Command event handling method:
Private Sub Linkbutton1_Click(ByVal sender As System.Object, _
ByVal e As CommandEventArgs) _
Handles Linkbutton1.Command, Linkbutton2.Command
Select Case e.CommandName
Case "ShowEditor1"
Editor1.Visible = True
Editor2.Visible = False
Case "ShowEditor2"
Editor1.Visible = False
Editor2.Visible = True
End Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top