How to get the Client side values in server side code.

Hi all,

i have a proble i need to get the client side javascript values in C# code at server side.

how can i pass those values?

i am using version 1.1, i kno thatwe can use callback events mechnisam in 2.0 or ajax ,apart from that how we can pass?

My problem is i need to stop the execution of the code based on after reciving values from the client

 

any ideas please???

 

Million thanks

Ram


Cheers
Ram MCP
0
ramana123
8/11/2006 9:44:45 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

6 Replies
1569 Views

Similar Articles

[PageSpeed] 53

Hello Ram,

a common approach is from javascript set an hidden field, then issue a postback. On the server-side, handle the post-back.

Feel free to go deeper in your question.

HTH. -LV


Julio P. Di Egidio
Software Analyst Programmer
=BUSINESS AND SCIENTIFIC=
=SOFTWARE DEVELOPMENT=
http://julio.diegidio.name

(Peace X Love] = [++1)
0
LudovicoVan
8/11/2006 11:17:46 AM

Hi LudovicoVan,

In programming we need to get that hidden variable through the reqest.form or request.querystring based on get or post procol we have used. is it am right or correct me.

My main problem is in my c# code i used RegisterClientScriptBlock to execute some javascrit code and the javascript function will reuturn some value based on that i need to stop execution or continnue, this how i can achieve please?

 

any exmaples will help alot..


Cheers
Ram MCP
0
ramana123
8/11/2006 11:55:40 AM

ramana123:

> In programming we need to get that hidden variable through the reqest.form or request.querystring based on get or post procol we have used. is it am right or correct me.

That's an option (Request.Form i mean, as you are POST-ing back...). More commonly, make your input field runat-server, and you'll see it on the server-side as any other server control.

> My main problem is in my c# code i used RegisterClientScriptBlock to execute some javascrit code and the javascript function will reuturn some value based on that i need to stop execution or continnue, this how i can achieve please?

I'm afraid there is a misunderstanding here. Javascript executes client-side, while C# executes on the server. When you issue a RegisterXYZScript, that *will* output some javascript to the page upon rendering, and there you are on the client. From client you need to post-back to get to the server. You cannot intermix them...

For a very long running process, you might think of starting an async process on the server (i mean in another thread, or similar) and straight return your request to the client. Then the client will poll the server to see whether the background process has finished or not. This might be a self refreshing page, or an AJAX callback, etc. etc.

So, you are trying to do something not very trivial...

-LV


Julio P. Di Egidio
Software Analyst Programmer
=BUSINESS AND SCIENTIFIC=
=SOFTWARE DEVELOPMENT=
http://julio.diegidio.name

(Peace X Love] = [++1)
0
LudovicoVan
8/11/2006 12:07:48 PM

LudovicoVan,

do you mean we cannt stop the execution of the server code based on the cilent side javascript values?

can you explain me which code is executed first like server side or client side?

i have added a attribute like "onclick " to the button and also server side event onclick also added.

but when ever i ran the application first its executing the javascript and then going to sever side code.

can you let me know why the execution happens like this as per my view after execution of the server side the page will send to the client then the client side code will be executed.

could you please explain me this?

or any related links or articles  would help me out.

 

 


Cheers
Ram MCP
0
ramana123
8/16/2006 6:31:46 AM

Because that is the process known as post back communications.

It goes client side generates the page, client submits page (can be a submit, or an interaction with a web form object like a checkbox with auto-postback = true), then server generates the page on the server side (server side on_load event fired), then the server side handles any specific client side object events(like an onClick eveny), then the server posts the information to the client, and finally the client load the information from the server.  Then the process repeats.

To break away from this fundamental form of communication is when you get into ajax (or known as Atlas in the microsoft world)

0
Windowns
8/16/2006 7:38:00 AM
Ramana123,
Instead of using an <asp:button> try using an old fashion Html button
<input type="button" onclick="YourClick('MyButton','args')">

function YourClick(context, args)
{
    //WhateverClientSideCodeYouWant
    __doPostBack(context, args);
}

on the server
controlName = Request.Params.Get("__EVENTTARGET");
arguments = Request.Params.Get(__EVENTARGUMENT");

This will insure that your client script runs before the postback.  You could also make a call to the callback function or create an XMLHTTP request object if you don't want to do a postback, but those are beyond the scope of your question.

0
eulalie
8/16/2006 7:48:23 AM
Reply:

Similar Artilces:

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 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 read cookies value on client side from server side code?
 I read an article which explains on how to read the client side cookies from C# code by doing something like://Grab the cookie 9: HttpCookie cookie = Request.Cookies[strCookieName];I am very confused here. Server side code in on the server side, so how can a server side code read the cookies on the client machine?I thought that only a client side script like Java Script  can read the client side cookies.Kindly explain...please.thanks.   Each time you request a page on a domain, the browser looks for a cookie for that domain on the client machine if it exists then it ...

How to take value from client side control from server side code?
Hi all, I would like to know that, how to access client side control in server side code? Here is an example.. I am having the textBox in client side like <input type="text" id="textBoxUsername" name="textBoxUsername"/> I need to take the value from this textBox in button click event which is server side code. private void buttonShow(object sender, System.EventArgs e) { //I need to access this textBox here. } How to do that? Thanks R. eswaran. hi you need to make it run at server. <input type="text" id="textBoxUsername"...

I need to get a server side button to run this client side code?
I need to get a server side button to run this client side code when the server button is clicked and then subsequently called by the server. Is it possible? The problem is that the print control is a client side activex. I can call it normally using a client side button but this is no good when I need to print more then one page. Any help would be great. Thanks. The code: function PrintProc(){ var MyPrinter; MyPrinter = new ActiveXObject("ImgXPrint6.ImgXPrint"); MyPrinter.PageFrom = 1; MyPrinter.PageTo = 1; MyPrinter.PageM...

client side code & server side code
what is the difference between client side coding & server side coding ? when to use client side & server side code? Client side code runs on the user's browser and includes languages such as javascript and vbscript. Server side code runs on the web server and can be written in languages such as ASP.NET, PHP, ASP, ColdFusion etc. Website Design Darlington - http://mdssolutions.co.ukhttp://lessthandot.com - Experts, Information, Ideas & Knowledgehttp://aspnetlibrary.com - An online resource for professional ASP.NET developersPlease remember to click "Mark as Answer...

Atlas client side control value available to server side C# code behind
I have an existing ASP.NET application. The page contains a datagrid (asp:datagrid). In my current C# code behind, I fetch data from SQL Server 2005 and bind to the datagrid when a button is selected (Click event). There can be many entires in the grid however, so the user typically enters text in a textbox as a filter on the returned results from SQL Server 2005. Now after studying an Atlas sample animalservice http://atlas.asp.net/docs/atlas/doc/data/default.aspx, with an HTML suggestion text box, I would like to use client-side Atlas to give the user a better indication of...

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

client side and server side code
Making things clear:When creating a web application one must know the difference between client side code and server side code.client side code is the code that is executed on the computer of the user. server side code is the code that is executed on the ....server.why is there client side code and server side code?well... server side code exist for the reason of sharing data with multiple users. for example: accessing a database.ASP.NET is a server side technology. in ASP.net you can use different languages such as VB.NET or C#.client side code is used to perform tasks on the computer of th...

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

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

How to Access/Pass Server Side Array Variable at Another Web Form's Client Side
Hi All,I struck up with some intrested senario at my application development...hope some body will guide me or sends me some code snippets....Thanks in advance.Senario is like this.....in A.aspx (using C# .net 2.0 as code behind) I am going to have a array variable basically it is an TWO Dimensional array after populating the values in array I need to redirect/ reload another web form B.aspx, here i need to access the array in B.aspx client side JavaScript.How can I do this...Thanks AgainRaju Dont do a redirect but use server.transfer. That way the previous page will still hold its value, ...

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

Client side to execute server side code
I am maintaining an ASP.NET C# application written by someone else.  I am essentially a newbie to web development especially client side stuff.  Based on reading these forums I understand that I can't directly call a server side method from the client side and I have to use post pack in some way (using a webservice is not an option here).  My confusion comes from the HTML setup being used.The page has three frames; a header, body and footer.  Each frame is filled by it's own ASPX page.  The footer contains buttons for navigating to another page and some of the b...

Web resources about - How to get the Client side values in server side code. - asp.net.web-forms

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

Brisbane massage therapist denies putting hands in client's underwear
A massage therapist on trial in Queensland for sexual assault has denied putting his hands inside the underwear of a female client who was seeking ...

Client’s “Great Thanksgiving Listen” Campaign Featured on Google Homepage
We love when our clients are successful, and StoryCorps and their amazing Thanksgiving Listen campaign being featured on Google’s homepage certainly ...

9 Ways To Lose Clients
Columnist Gary J. Ross explains how NOT to treat the client.

Agencies Should Follow Clients' Lead on Diversity
A few weeks ago, PepsiCo's Brad Jakeman called out advertising agencies for not evolving with the times. Most important, he criticized them for ...

When Clients Don’t Pay: Legal Options for Freelancers
It’s a worst case scenario for a freelancer. After spending valuable time and energy completing a project to your client’s exact specifications, ...

Guggenheim Securities' clients - Business Insider Deutschland
The 16-year-old firm has been an adviser on 5 massive transactions in what has been one of the busiest years for mergers and acquisitions on ...

Lawyer defends cop who shot teen 16 times, says client feared for life
The lawyer for the Chicago police officer who fatally shot 17-year-old Laquan McDonald defended his client Friday, saying the officer feared ...

Resources last updated: 12/3/2015 9:55:34 AM