How do I pass client side values to server side ones & vice versa


If I have some jscript that creates a value based on a users input, how can I pass that to a server variable?

Many thanks

4/3/2008 10:25:07 PM 24353 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 20


You can set that value to a hiddenfield (runat = server) on the client and then read it from server side like any other control.

If this is not clear, please paste your code so I may help you better.


Simplicity: "the art of maximizing the amount of work not done."
4/3/2008 11:05:11 PM

Thanks for your time crfenix, 

I need to do something like below:

Code behind:

protected void Page_Load(object sender, EventArgs e)


string[] myOP = {"test1", "test2"};



 client side javascript

function buttonClientSide_onclick() {

var myOP = '<% = myOP %>';  // here i get an error



Any ideas on this would be very much appreciated


4/4/2008 12:39:11 AM

Your idea fit very well with "ClientScriptManager.RegisterArrayDeclaration". This register an array from codebehind that it's accesible from javascript


Simplicity: "the art of maximizing the amount of work not done."
4/4/2008 2:02:34 AM

Similar Artilces:

How to pass values from client side to server side
Hi, Is there a way to transfer variable from a client loop to a server loop. For example: var clitest = 'test'; Now I would like to get test variable from javascript into a server string variable <% sertest = ?? %> I understand that this can be done by storing a variable into a hidden control for example and than access it using server side, but when I have to transfer an array for example it get's a little more complicated. I was wondering is there more efficient approach? You can't transfer arrays, only strings. To workaround this problem pass delimited stri...

How to pass the client side values to server side?
 hello to All,Actually i wanna implement a code like... a string in HTML textbox retrieve in server side control....suppose i hv a HTML control <input type="text" id="txtHTML"/>, and dis control  txtHTML.text="abc".now i want to retrieve dis client side string "abc" in d server side textbox named "txtASP"...which hs a property runat="server"so please give me an idea how to pass values from client side to server side.... hope u understand a problem... sam.  You could do this <input type="text"...

Problem passing value client-side to server-side
I have a page that calls a pop-up while passing an encrypted value via a query string. The value is encrypted on the parent client-side in javascript so it needs to be decrypted client-side as well. This decryption occurs on closing the child (popup) and I am at a loss of when and how I should get this value to the server-side. On the popup you just want to process server side code? Anytime you can access for example the raw url:string raw = Page.Request.RawUrl;If you need to access any values on the client side you can access the url using javascript. Another idea is to, on the code beh...

how to pass values from client side to server side #2
Hi Guys....               This is Aani....I'm using ASP.NET in C# language.i have created one webpage for get input from user(from java script inputbox).i want that entered data in server side can i pass that value from client side server side.i need proper code in C# language.reply me soon... Thanks is Advanced... Regards....Aani plz use hidden field.ur assing values to text boxes through java script. before post back call a java scipt function to assign value to hodden fieed. even u can add these ...

passing client side variable value to server side
 i have a grid and  by click on the rows, the onrowclick event is fired on client side. I want to pass the row index to the server side. As there are not sessions variables in javascript so i am stuck to pass the row to the server side.. I have made a texbox and set its valueto the index in the onrowclick event but when refresh calls, the text box became empty as the value set is on client side, i want page to persistthe value,  How can i do that? Tel me some way passing the row index to the server side?? Hi, You can call GridView_SelectedIndexChanging event on row click ev...

Passing a value from server side to client side without postback
My problem exactly is that on my aspx.vb code-behind, I can update the field using HiddenField ID = "hidSessionTimeout" Code-Behind: on Page_LoadhidSessionTimeout.Value = HttpContext.Current.Session.Timeout on ChangeTimeOutValue()hidSessionTimeout.Value = 5  Client-Side: var x= document.getElementById("hidSessionTimeout"); It seems that the javascript cannot get the latest updated value... Any ideas?    Any Workaround solution? did u keep the page load code in if(!IsPostBack)pavankumar geljian_a:  Client-Side:  var...

Client side code to pass values to server side variable?
Hi there, I have ListBox_SelectedTextChanged() method that creates another list box in the runtime as follows: // Get Action Level List lbxActionLevel = new ListBox();lbxActionLevel.ID = "ddlA" + i.ToString(); lbxActionLevel.Width = 100; lbxActionLevel.Rows = 2;SqlDataReader dr = new BusinessLogicLayer().bllGetActionLevels(); lbxActionLevel.Items.Clear();while (dr.Read()) {ListItem lAction = new ListItem(); lAction.Text = dr.GetString(1).Trim();lAction.Value = Convert.ToString(dr.GetInt32(0)); lbxActionLevel.Items.Add(lAction); lbxActionLevel.SelectedIndex = 0; } I ...

How to pass param values from server side to client side scripts
Hi, I have a page containing a datagrid with a list of geographic positions of interesting places. Users can filter this grid. Clicking an item the system displays the place on a map using MS Virtual Earth map component that exposes a client side javascript api. My problem is that the filtering is done on server side, but the map runs on client side. So during page load, I need to create long strings containing complex javascript codes on the server side, and add it as an event handler attribute to my components. This causes a lot of problems, for exemple...

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 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: In the JavaScrip...

server side control passing value of self in client side function
I have a server side dropdownlist control.It contains values as:"#00FFFF""#FF00FF""#FFFF00"When the selectedindex is changed by the client I want to assign the value of the dropdownlist to a <div id="example"></div> evelement.pseudo:document.getElementbyId('example').bgcolor=dropdownlist.valueHow can I do this? I think I somehow need to attach a function to my dropdownlist which passes its own value as a parameter to a function...any suggestions?Thanks!please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already. You ...

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

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click ( and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

How to pass server side array to client side
Hello Friends.....   i want an intelligent textbox.....which pop up a list of data when any character is pressed in perticular textbox.......... the data should be related fields which are stored in database .........   for that i am having a javascript...........but it is static has a static array and generates output..... but i want that particular with my own datafields.......   so please any one help me...... i will be very thank full........   Thanx and regards sandeep prajapatiBhaaratRemember to click "Mark as Answer" on the post t...

Web resources about - How do I pass client side values to server side ones & vice versa -

Fat client - Wikipedia, the free encyclopedia
the name is contrasted to thin client , which describes a computer heavily dependent on a server's applications. A fat client still requires ...

Facebook Forms EMEA Client Council
Facebook announced the formation of its EMEA Client Council in a post in Spanish on the Facebook for Business page by vice president for Europe, ...

Facebook hires: Carsabi team, head of policy France, marketing mix science lead, client partners and ...
... Manager (Prineville) Chief Facility Engineer (Prineville) SMB Associate, French (Dublin) User Operations – Contract (Menlo Park) Client ...

Lawyer labels client 'stupid' after New Year text to ex lands him behind bars for a week
Man's five days in prison for New Year text was significant &quot;wake-up call&quot;, lawyer says.

Canberra psychology clinic accidentally reveals clients' personal details in email
A Canberra psychology clinic has apologised after it accidentally shared personal details of hundreds of patients in a group email.

Anchorage Assembly candidate drops out rather than reveal tutoring clients
... Anchorage Budget Advisory Commission, has withdrawn a bid for the Assembly because she did not want to list the names and addresses of clients ...

Spotlight On NW Creative: Fell Swoop And Its Unique Client Mix
After living in Seattle for a few years, it’s become clear to me that many shops here struggle to capture significant business from clients headquartered ...

New online FX broker group rails against client money laws
A group of online broking firms have launched a desperate bid to sway the government on its proposed client fund segregation laws.

SanDisk Announces X400 Client SSD for OEMs
... Like the X300, the X400 uses TLC NAND flash and relies on SLC-mode write caching to provide competitive write speeds. SanDisk OEM Client SSD ...

Resources last updated: 1/21/2016 2:42:17 PM