Monday, March 26, 2012

Maintain viewstate

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,
AbhilashInstead 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
Instead of passing QueryString parameter between 2 pages, place both control
s
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
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Abhilash" wrote:

> 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
>

0 comments:

Post a Comment