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.
 

0
asmussen
8/28/2007 9:53:35 PM
asp.net.ajax-discussion 13973 articles. 1 followers. Follow

5 Replies
1052 Views

Similar Articles

[PageSpeed] 22

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.

Latest article: Using complex types to make calling services less… complex
0
gt1329a
8/29/2007 4:19:44 AM

I made a mistake in my original post I meant to say "without post back" 

0
asmussen
8/29/2007 4:45:43 AM

A page method might be a good way to do it, depending on what you're trying to do. 


Encosia - ASP.NET, AJAX, and more.

Latest article: Using complex types to make calling services less… complex
0
gt1329a
8/29/2007 4:47:50 AM

I took a look at pagemethods but they seem to be used for accessing C# method from javascript I need to do the opposite. plus pagemethods are limited to static methods.

At the risk of complicating the question here's my situation. I have an activex object that has a javascript interface. The activex causes a javascript function to fire and the function receives some data from the activex control. 

I need to access the data from the Javascript function some how from C# codebhind. I was hoping I could access it from a C# code behind using something like or unlike this:

function GetData(someinput) //someinput will be coming from the activex object

{

    return "Here's some output:" + someinput;  

It would be nice if I were able to call that function from c# codebehind:

public string GetOutput()
    {
        string Output = GetData();

        return Output;
    }

Currently I am populating a server side text box from javascript and I am trying to access it everytime it changes with the TextChange event but that event requires user interaction to set focus out side the textbox.

I am in desperate need of a solution.

Thanks, Justin. 

0
asmussen
8/29/2007 10:21:52 PM

Unfortunately, since the HTTP protocol is stateless, you can't directly initiate client side actions from the server side.

If this ActiveX control is something you have the ability to modify, you could have it maintain bidirectional contact with the server or have it poll the server for updates to whatever would cause you to update this hidden TextBox.

If you need a JavaScript solution, probably the best bet is something like this:  http://encosia.com/index.php/2007/07/25/display-data-updates-in-real-time-with-ajax/

Using that, you could poll the server directly for whatever condition requires interaction with the ActiveX control.  Page methods are light weight enough that you can poll pretty frequently and it's not a huge burden (depending on what happens in the method, of course). 


Encosia - ASP.NET, AJAX, and more.

Latest article: Using complex types to make calling services less… complex
0
gt1329a
8/30/2007 1:17:40 AM
Reply:

Similar Artilces:

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

When To Use Client Side vs Server Side vs AJAX
Before AJAX, it was fairly clear to me where to draw the line between functionality best performed server-side vs client-side.  For example, database access and data processing is done on the server, and basic field validation and other UI stuff is done on the client.  But now with AJAX implemented through Atlas, the line is blured.  I know what can be done... but what is the optimal way to design a web application using Atlas (in terms of what functionality should be implemented server-side versus client-side versus Ajax)?  What is the prev...

Sending array data with hidden input field from client side to server side
I have some values that I'm sending with javascript to the server side code via a hidden input field.  This works great.  However, I want to find an elegant way to split the values up on the server side.  What I have below works, but it doesn't seem like a very clean solution.  Client codevar values = '&approved=1&funded=0&winprob=2'; document.form1.ipHidden.value = values.toString(); Server codeDim strValues As String = ipHidden.Value.ToString() Dim strApproved = strValues.Substring(strValues.IndexOf("approved=") + 9, 1)Dim st...

How to Pass Information from Server-Side Code to Client-Side Code in AJAX Control Extender?
Hi All,For some reason I can't get the following to work: I have a custom AJAX Control Extender with a few getters and setters. I also have some images I want to use with the extender saved in a resource file. How to I make the respective image URLs available to the javascript of the extender? Are there any examples available?Thanks![Update: renamed the subject to something more appropriate.]  Perhaps I can clarify a bit:I have set up a getter and setter to set the image URL from the resource file: 1 [ExtenderControlProperty] 2 public string CoverURL 3 { 4 get...

when to use client side / server side?
Hey, Please can someone tell me when do i need to use a client-side or a server-side? For instance, I have a dropdownlist and when the user choses one of the listitems then click on the button to submit changes,i need first to validate the new value chosen by the user by comparing it with the old value and then redirect the user to the next page if there are no errors or view an error on the other hand! so in this case what's more preferable to use a JScript (client side) or on the click event of the button pressed (server side)! waiting the reply................. thanx in adva...

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

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

Passing variable between client side and server side
For example,how do I pass the return value of the confirm("whatever") to the server side? Or the opposite way.  I want to use a cookie to do is. Can some one give me hint.  Much appreciate your help.   Chen  Please "Mark as an Answer" if you think my post had helped you!Thanks. you can use ajax,javascript and cookies also.  Got what you needed. Please mark as answer. In the aspx file: <input type="hidden" id="confirmAnswer" name="confirmAnswer" runat="server"> That adds this to the...

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 (Asp.net) 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 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 operations.how 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 ...

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

pass array object from client side to server side
dear all, i need to pass objects from client side javascript to server side  is there any way to do that..  i have tried hidden field but we can't assign array objects to the hidden fields is there any other way to store array object in server  URGENT!!! Thanks. raj  URGENT, I waited to the last minute to get HELP! I am screwed! No one cares it is urgent!You need to convert it to a string. If it is an Array, use the join() method and store it to a hidden field.  Eric Pascarello.com | Twitter epascarello | LinkedIn LOL, ...

Passing parameter from Javascript(client-side) to server side
Hi guys, I'm having problems with my code. I have a textbox1 and a submit button and another textbox2. When my user enters a value into textbox1 and click submit, the description text should be returned to textbox2. Here's my code: Javascript(client side) : function CheckValue() { var stdNo = document.getElementById('Textbox1'); if (stdNo.value != null) { What to code here to pass the parameter value to my server?? } "TextBox1" runat="server"> "Button1" runat="server" OnClientClick="CheckValue(...

Web resources about - Passing client side to server side using hidden field - asp.net.ajax-discussion

Passing loop - Wikipedia, the free encyclopedia
Trains / trams going in the same direction can also overtake, providing that the signalling arrangement allows it. A passing loop is double ended ...

Facebook Gets Passing Grade From Irish Agency Audit - AllFacebook
Facebook received its report card in the form of a detailed audit by the Office of the Irish Data Protection Commissioner, and its grades were ...

Dan Aykroyd - Deeply saddened to hear of the passing of my... - Facebook
Deeply saddened to hear of the passing of my brilliant, gifted, funny friend, co-writer/performer and teacher Harold Ramis. May he now get the ...

Thread: Buck-passing bullshit.
The Repubs are tempting fate, trying to allocate blame for Obama's loss in November. Obviously it's a little presumptuous. If Romney wins, it's ...

Scripting News: People are asking about the history of RSS today because of Aaron's passing.
People are asking about the history of RSS today because of Aaron's passing. In April 2004 I put together a timeline of the various specs that ...

The secrets of passing TOEIC 600 - ValueEnglish on the App Store on iTunes
Get The secrets of passing TOEIC 600 - ValueEnglish on the App Store. See screenshots and ratings, and read customer reviews.

walmart donated a palette of water. everyone was great about passing the bottles back - Flickr - Photo ...
Explore pinguino's photos on Flickr. pinguino has uploaded 16442 photos to Flickr.

Straight Rod Passing Through Curved Hole - YouTube
To use this video in a commercial player or in broadcasts, please email licensing@storyful.com Here is the explanation on how it works​ ;) h ...

Passing of UAE companies law delayed
The council was scheduled to convene today to debate the remaining four articles of the 377-article law, but were told by the Minister of State ...

Cabcharge left with a hard road after Reg Kermode's passing
Reg Kermode's company faces testing challenges after his death, writes Colin Kruger .

Resources last updated: 1/14/2016 11:08:21 PM