Using hidden field to store value then calling that value from client side

I have three tabs (1,2,3) on my main page each tab contains a datagrid... when a user select a tab then leaves the main page and returns to that main page(without exiting browser) I need for the page to open with the tab last selected by that user so that they can pick up where they left off. No one can seem to help me with this issue....

My javascript (client side) code function is as follows:

<asp:HiddenField ID="hdnNewPanel" runat="server" />

<script language="javascript" type="text/javascript">

 

function SwitchPanels(newPanel)

 

{

if(newPanel == 1)

{

tdTasks.className=
'ptsSelectedLeftmostTab';

tdNotices.className='ptsUnSelectedTab';

tdQueries.className='ptsUnSelectedRightmostTab';

 

taskDiv.className=
'ptsOpenDiv';

noticeDiv.className='ptsClosedDiv';

queryDiv.className='ptsClosedDiv';hdnNewPanel = "1";

}

else if(newPanel == 2)

{

tdTasks.className='ptsUnSelectedLeftmostTab';

tdNotices.className='ptsSelectedTab';tdQueries.className='ptsUnSelectedRightmostTab';

 

taskDiv.className='ptsClosedDiv';

noticeDiv.className='ptsOpenDiv';

queryDiv.className='ptsClosedDiv';

hdnNewPanel = "2";

}

else if(newPanel == 3)

{

tdTasks.className=
'ptsUnSelectedLeftmostTab';

tdNotices.className='ptsUnSelectedTab';

tdQueries.className='ptsSelectedRightmostTab';

 

taskDiv.className=
'ptsClosedDiv';

noticeDiv.className='ptsClosedDiv';

queryDiv.className='ptsOpenDiv'; hdnNewPanel = "3";

}

 

}

 

</script>

<script type="text/javascript">public int function getValue(newPanel)

{

string hdnNewPanel;

document.getElementById (
'<% =hdnNewPanel.ClientID %>').value = hdnNewPanel;

 

}

</script>

 What should my server side (code behind) be that would call the tab selection from client side hidden field and invoke it into main page when returning?

0
thea3100
8/7/2008 6:52:57 PM
asp.net.client-side 24353 articles. 1 followers. Follow

10 Replies
1057 Views

Similar Articles

[PageSpeed] 17

thea3100:

I have three tabs (1,2,3) on my main page each tab contains a datagrid... when a user select a tab then leaves the main page and returns to that main page(without exiting browser) I need for the page to open with the tab last selected by that user so that they can pick up where they left off. No one can seem to help me with this issue....

what do you mean  by that


A fine is a tax for doing wrong. A tax is a fine for doing well.
__________________________________________________
Please remember to click “Mark as Answer” on the post that helps you.
0
etariq
8/7/2008 8:35:06 PM

Hi,

You are storing the current tab id in the hidden filed. In this case, if the user leaves the page and go for the other page, the value in hidden field would be lost. So next time when they come back to the screen, you would not be able to retain the tab's position.

Try to store the current tab position in the session value. Then always populate the tab's value from session. 


Rajganesh
__________________________________________________
My Blog
If this post answers your question please mark it as Answered.
0
Rajganesh
8/8/2008 3:40:36 AM

I tried using sessions before and couldn't get that to work, that is why I resorted to hidden field.  Can you point me in the right direction with maybe some sample code perhaps? All I want it to do is keep the tab number selected into session for reuse while the session is still active. I'm not storing anything once the browser is closed.  So if the user picks tab one, then leaves the main page to do something else, when or if they do return to the main page, tab one will still be selected.  No one can seem to figure this out for me......

0
thea3100
8/8/2008 1:06:10 PM

The only way that you could use Session state would be to do a PostBack, since Session state is ONLY available in the server-side code. The easy way is to create properties in the CodeBehind. Here is a simple example.

protected string YourVariableName
{
 get
 {
  object sessionObject = this.Session["YourVariableName"];

  if ( sessionObject == null )
  {
   // Set to some default value
   sessionObject = "";
  }

  return (string)sessionObject;
 }
 set
 {
  this.Session["YourVariableName"] = value;
 }
}

protected void Page_Load(object sender, EventArgs e)
{
 if ( this.IsPostBack )
 {
  YourVariableName = yourHiddenField.Value;
 }
 else
 {
  yourHiddenField.Value = YourVariableName;
 }
}

NC...

0
NC01
8/8/2008 2:38:16 PM

Thank you, now I'm getting The following error:

 

"the namespace '<global namespace>' already contains a definition for '?'

0
thea3100
8/8/2008 7:09:44 PM

try using query string. if query string is not empty set the value to the default tab otherwise set it to the value in the query string. you can also use sessions. let me know if this does not work for you.


Vamsi Komarneni
Microsoft Certified Professional(MCP)
http://vamsikomarneni.blogspot.com/
http://www.linkedin.com/in/vamsikomarneni
0
vamsi
8/8/2008 8:36:03 PM

thea3100:

Thank you, now I'm getting The following error:

 

"the namespace '<global namespace>' already contains a definition for '?'

I have no idea what could cause that, since I've never seen that error and I don't get it when I try what I think that you're trying to do. Post the code causing the error with an explanation of what you are attempting or what you expect to happen.

NC...

0
NC01
8/10/2008 12:39:37 PM

thea3100:

Thank you, now I'm getting The following error:

 

"the namespace '<global namespace>' already contains a definition for '?'

 

HI thea3100
 
This issue is not caused by NC’s code.
 
There is the solution from http://bytes.com/forum/thread574554.html
 

Dave Sexton:

Use the Find and Replace tool to search for all classes with the same name
as yours and either rename them or just rename yours :)


 
If I’ve misunderstood your problem, please feel free to let me know.
 
Thanks.

 


Lance Zhang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Lance
8/12/2008 5:42:09 AM

I am no longer getting the error when using NC01's server side code. But it is still not keeping the tab selection.  Should I be still using the javascript code for the hidden field?  here's what my server side code looks like so far:

 

protected string YourTabSelection

{

get

{

object sessionObject = this.Session["YourTabSelection"];if (sessionObject == null)

{

sessionObject =
"1";

}

return (string)sessionObject;

}

set

{

this.Session["YourTabSelection"] = value;

}

 

}

if (!Page.IsPostBack)

YourTabSelection = hdnNewPanel.Value;

else

{

hdnNewPanel.Value = YourTabSelection;

 

}

 

thanks for all your help...I'm getting close, there's just something I'm missing..that's where you experts come in, I'm a very novice user! thanks again!

0
thea3100
8/12/2008 2:26:21 PM

> Should I be still using the javascript code for the hidden field

Of course. That is what actually sets the menu visibility isn't it?

NC...

0
NC01
8/12/2008 2:31:29 PM
Reply:

Similar Artilces:

Use client side code to get hidden field value from calling page
Hi, I have a web application that is being called from an extranet app. I need to access the value of a hidden form variable on the calling form, I have tried Request.form("Fieldname") & cannot pick up any values. They are not keen on passing the value in the querystring - I would really appreciate some help on this. Thanks If the item is not in the form collection, then they're probably not doing a POST to your page. You can pass information to a page three ways: URL (querystring, fragment, etc), POST (form.submit()), and via a HTTP Header. They'll need to decide...

Issue obtaining values in server-side from dropdownlist when updating value using client-side script in master page
HiI got a page in a contentplaceholder of a master page. There is two pulldowns. I populate the first one using server side coding and then use client-side javascript. So far so good. The issue is that upon a postback I try to collect the select value of the second pulldown and there is no data in the pulldown and no selected item. I tried using control.selectedvalue (nothing) or searching the form controls Stringvariable = oForm.FindControl("Control")Thing is I've done this before in 1.1 outside of a master page and it works.Thanks in ad...

How can I set client side values as server side values?
Hi, Can anyone tell me how I can get client side values such as document.referrer, navigator.appName etc... into server side scripts? There are some client side values I'd like to set as session vars and insert into the db? How do I go about this? Thanks for any pointers Davlon PS (I'm using powersite 7.1.0.300) Pass them as page parameters, e.g., http://myserver/myurl?document.referrer=whatever&navigator.appName=yadayada Then, in your server-side script, just loop through the document.value array and get these values. -- pbm_hopethishelps, Roy Kie...

Passing client side to server side using hidden field
 I have a hidden asp.net text box that is being updated on the client via javascript. I am trying to determine the best way to detect when that hidden field has changed and read the new value on the server. I would like to do this WITHOUT posting back. I have tried using the TextChanged event but that requires blur state to be changed before it gets fired. What would be the best way to do this? Thanks, Justin.  Can you use __doPostBack() to trigger a partial postback at the same time the hidden TextBox is updated, from JavaScript? Encosia - ASP.NET, AJAX, and more.Lates...

Getting hidden variable value from server side in client side
hi,        I am struck in problem. I have a hidden field in my form and i am setting some value in that.         Now i wnt to use this value from client side but i m not able to retrieve it. All i am getting there is an object.         I feel the hidden field is not able to hold that value.         <input type="hidden" id="hdnVar" runat="server" />         in code behind      ...

Client-side values to server-side ?
Hi! My previous query is attached below: I have implemented the below mentioned implementation . 'listbox1' on 'webform1' shows all the values from 'webform2'. I have implemented it using javascript. I would like to know that to implement validation on 'webform1', I would require the values of 'listbox1' ,which are on the client-side , to move to the server-side . I think sending a querystring will be fine but how to implement it using javascript and code-behind(C#)? Your suggestion will be appreciated. Thanks and regards, ap.       My previous query: " I am stuck wi...

Client side set hidden field value not POSTing back
 hi,(sorry, I dont have any code snippets to hand as I'm away from the dev machine at the mo)I have a page which makes two seperate WebServce calls for data. One is via an Ajax call, the other is server side.The flow is as follows:1. Ajax Web Service call returns a collection2. In the js script file, read the PK's of the collection and set a hiddenfield with the comma-seperated keys3. initiate a __doPostBack call from script - target an update panel on the page which then calls the second Web ServiceThe problem I am experiencing is that after I have made the first call and ...

Client side Values to Server values
Hi all, I'm using Visual Studio 2005 and C#.Net  I have one big security problem. I have one web page for user login. When user click in button "Login" i run some functions of javascript for detect pki credentials and i write the credentials in some textboxes. When the login process end, the user must click in another button for redirect the application to another page. I want pass the login credentials to target page, but i can´t use querystrings in url because is not secure ans i don´t want use cookies because some users have disableded cookies. I want...

Change hidden field value on client side, then retrieve on serverside
I am trying to change a hidden field's value on the client side with Javascript, then retrieve it after postback.The hidden field is inside a user control. The user control's containing page attempts to access the hidden field's value in a click event handler, but the hidden field's value still has the old value.However, by the user control's prerender phase the hidden field does contain the new value.I notice that if I use Request.Form, the same behaviour is exhibited.How can I retrieve the hidden field's new value, without having to wait for the prerender stage. Or alternatively, how can I...

Hidden field client side value lost on post back
Hi, I have a checkbox list , two text box , with link to javascript calendars and two hidden fields. The checkbox list contains years with start and end date in text part and the two textboxes are From and To date. Initially when the page is loaded the first year in the list is checked then the hidden field for start and end date is set at server side. After that on client side onload we run a javascript that picks up the date from hidden fields and set them on the two dates textboxex respectively in client locale. No when i change the checkbox check the repect date in text part of the ...

Client Side values to Server Side
What is the best way to transfer Client Side values to the Server side? For example I have a variable "var1" in javascript. var1 = "sample"; How can I acquire this value in the server side?  What is the best approach for this?  Barry to send the value to the server during a postback, you need to place the value in an input control.  You could consider using a hidden textbox for that purpose.Mike Banavige~~~~~~~~~~~~Need a site code sample in a different language? Try converting it with: http://converter.telerik.com/ In the JavaScrip...

Storing the checked Htmlimputcheckbox values on client side and passing to server side on submit button clicked
Hi All  I've got these bunch of HtmlInputcheckboxes that i'm creating dynamically using div.innerhtml on server side and putting it in a <TD> block, calculate averages etc. Things are working fine until this point. Now i need to get all the checked checkboxes and their values(which are dates in my case) and pass these values back to server side for processing on the submit button click. But i'm using a pagefooter submit button to fire my submit button so i cannot directly pass these values to my submit button onclick method. I tried to use the findcontrol method ...

Hidden Field that is set on server side...not getting the last updated value from client?
Hi, I have a hidden field that tracks errors in my server side asp.net 2.0 code.  However, when I set the value to an error (from it's default value "NotSet") in the server side code and then when trying to access that Hidden Variable from the client the value is still set to the default value, "NotSet" instead of the error information. Any ideas as to what is going on here? Thanks in advance!   Server Side....  catch (Exception er) { Errors.Value = er.Message; o o o } Client Side.... function getErrors() { var cho = document.getElementById('<%=Errors.ClientID...

pls help: how to get client-side HTML "text field" value from a server side button
i copy some javascript from somewhere so user can choose pick up a date from a calendar and display the date onto a HTML text field. I have no knowledge in writing client side script(i.e. write code in html) can i write some code in a server-side button to get the value in the HTML text field??? i tried: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click textbox1.text = document.getElementById("htmltext").value End Sub but "document" is highlighted, and say isn't declar yet. and...

Web resources about - Using hidden field to store value then calling that value from client side - asp.net.client-side

London Calling - Wikipedia, the free encyclopedia
London Calling is the third studio album by the English punk rock band The Clash . It was released in the United Kingdom on 14 December 1979 ...

List of country calling codes - Wikipedia, the free encyclopedia
This is a list of country calling codes defined by ITU-T recommendations E.123 and E.164 , also called IDD ( International Direct Dialling ) ...

Free VoIP Calling Added To Facebook Messenger For IOS In The U.K.
Voice-over-Internet-protocol calling has made its way across the pond for Facebook Messenger users, as the social network updated its iOS version ...

Facebook Video Calling - Facebook
Bring your conversations to life on Facebook. With face-to-face video calling, now you can watch your friends smile, wink and LOL. To get started, ...

Facebook roundup: video ads, voice calling, logos and more
... than three per day at launch. It is unclear whether the ads will autoplay in the feed or not. More Messenger for Android users get free calling ...

Berlin Calling (@neuraum) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Calling all foodies: Here comes @TwitterFood
There are many thousands of food-related Tweets people send on Twitter each day – Tweets about meals, ingredients, favorites, recipes and dining ...

YUBISASHI NIPPON CALLING ENGLISH for iPhone, iPod touch, and iPad on the iTunes App Store
Get YUBISASHI NIPPON CALLING ENGLISH on the App Store. See screenshots and ratings, and read customer reviews.

Calling woman II - Flickr - Photo Sharing!
Explore Marcel Oosterwijk's photos on Flickr. Marcel Oosterwijk has uploaded 2195 photos to Flickr.

China Calling: Huawei’s Media Tour, Kirin 950 and Why We Went
Sometimes the only way to develop a relationship with a technology manufacturer beyond a simple press release exchange with a media relations ...

Resources last updated: 12/10/2015 5:46:49 PM