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 i also tried:
textbox1.text=request.form("htmltext")
I would be greatly appreciated for your suggestions, pls help~~~~~~~thank you very much~
0
ryukkl
3/9/2004 12:48:13 PM
asp.net.client-side 24353 articles. 2 followers. Follow

9 Replies
1482 Views

Similar Articles

[PageSpeed] 55

add properties id="" and runat="server" to the textbox to upgrade it to server control
0
rox
3/9/2004 9:02:42 PM
the copied javascript support only client-side textbox, error will occur if i change the textbox to server control.

but why need to add properties=""???any meaning?
thank you very much~~~~~~
0
ryukkl
3/10/2004 4:15:05 AM

Your statement is incorrect. You can still attach client-side code to a Server Control, however you have to do it by adding it to the appropriate Item (e.g. onClick) of the Attributes Property. For example:
    HtmlInputButton.Attrubutes.Add ( "onClick", "alert ( 'testing' )" )
Also, you don't add properties="" (which are actually called attributes), you add id="MyID" (replacing the MyID with an ID of your own), which simply gives the Server Control a unique name.

Steven Bey

Recursion: see Recursion
0
stevenbey
3/10/2004 12:29:54 PM
thank you all of you~

but pls try to stand in my situation: i can't change the textbox to server control since the copied javascipt is complicated, i don't know how to modify its content so it can pass the date (it's a calendar) value into a server-side textbox. (the javascipt is set to pass the date into a client side textbox)
how can i get the value display in the html text field from a server-side button??
thank you very much~~~~~~~~~~~~

0
ryukkl
3/10/2004 1:32:33 PM

My apologies.
You could always ditch your JavaScript and use a DatePicker control. Try this or this.

Steven Bey

Recursion: see Recursion
0
stevenbey
3/10/2004 2:20:59 PM
it is solved, thx~~~~~~~
0
ryukkl
3/10/2004 2:53:06 PM
stevenbey,

You seem to know your stuff...got a question...
I'm having trouble with javascript in my "usercontrols" because apparently when the ascx userconrols are rendered into an aspx page at run-time, the server renames all the controls contained in the ascx file...so that my javacode (where the original control names are hard-coded) no longer runs.
Especially critical when trying to talk from a pop-up window back to the parent to write values back and forth.
Do you know what I'm talking about? Have you dealt with this issue in your javascript journey...
thanks!
dave
0
DaViD
3/10/2004 9:12:41 PM
David,

I encountered this problem, say if you have a text box control (of id txtBox) in an user control (of id usrCtrl), the text box control gets rendered in html as
<input type=text id=usrCtrl:txtBox name=usrCtrl_txtBox/>
basically the id of the usercontrol gets attached to the id of the control as a prefix.
so, in your javascript attach the user control id as a prefix to the server control id.
Hope this will help you.
-Visak.
0
visakgan
3/10/2004 10:17:07 PM

Slight correction of Visak's example:
    <input type="text" id="usrCtrl_txtBox" name="usrCtrl:txtBox" />
i.e. the colon and underscore were being used for the wrong attribute. For an explanation of this see this thread.

Steven Bey

Recursion: see Recursion
0
stevenbey
3/11/2004 9:10:19 AM
Reply:

Similar Artilces:

using client-side script to "disable" server-side conbrols
hi all, not quite disable, i'll explain. i have a basic web form, some asp text boxes and some validation / required field controls. what im trying to do is hide the error messages displayed by the validation controls when the user clicks the form 'reset' button. can this be done using client-side, or will i have to do a postback? thanks in advance Dave You can change the 'CausesValidation' property of the Reset button to False. That'll stop the validation checks from running when you click on it. I have a blog. Perhaps you'd like to read it. TRY this ... <html> ...

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

MaskedEditExtender/Validator Behavior -- Simple client-side "IsValid"? Or server Side IsValid example...
Hello, Isn't there a client-side: behavior.IsValid(); ? I've been through the AjaxToolkit MaskedEditExtender (ME) and MaskedEditValidator (MEV) and can't find a way to simply query the ME or MEV as to the validity of the target. This works fine with several pure-javascript validators that I know, but I would like to use the ME/MEV. All I need is a client (ME Behavior) side interface to call when I hit a Submit button. If the validation succeeds, then I post-back, if not, it should do its thing, and post the configured error/validation messages to the target. This is a...

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 RamCheersRam MCP 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 que...

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

"Push" messages to Atlas/Ajax Client or Client-side event handling of server messages
What I'm looking for is the ability for the client-side Ajax/Atlas GUI to be able to update itself when events occur on the server. The issue is that the events are triggered from a third party, and aren't triggered by postback. For example, let's say there's a Queue of data on the server, and each time a new item is added to the Queue, I want the client to recognize the addition and display the new item. Right now, the only way I can think of doing this is by setting up an Ajax timer and checking the state of the Queue on every timer tick. While this doesn't cause the page to refresh/postba...

Developed C#.net WebService 1.1 for Client C#.net 1.1. Getting error "Server was unable to process the Request" Pls Help
Hi., I developed Microsoft C#.net Web Services2003 for the Client Application C#.net 2003. When it runs in 5 machines it gives good performance and has no errors. But if i run the same application in about 80 client machines. Getting error "Server was unable to process the request". I use Sql Server 2005 as my database. I get error even when i login at a time for about 25 users. Tried modifying machine.config too. But went unsuccessful. Live Server is 2003 using IIS 6.0 I use very expensive data handling.  Its very urgent pls help. Have to post in Live Server. Thank u., ...

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

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

can clear server side text box value from client side.?
Hi, function Disab() {    if(document.all.chkSPTariff.checked)     {        document.all.txtVFX.disabled=false document.all.txtVHSFO.disabled=false    }  else  {     document.all.txtVFX.disabled=true document.all.txtVFX.value=""               }   This is how i am clearing  the  text for <asp:TextBox>. Ofter i submit, i wonder to see the old value from serverside , like txtTemp.Text is h...

Client Side HTML Radio Buttons not Posting with Server Side Form
I have a server side form that is posting when an HTML client side button is clicked.  However, the value of my html client side radio button is null when I call Request.Form("htmlradiobuttonlist") on the resulting page.  Does anyone know why the form won't the post the value?  Please help!  Thanks in advance.I'm still using dot net 1.1.  I can use server side buttons or server side radio buttons.  I can explain why if necessary.Below, you can see the HTML radio buttons in the datalist.  The JS function works, but is omitted from below.<form id="form1" a...

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

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

Web resources about - pls help: how to get client-side HTML "text field" value from a server side button - asp.net.client-side

Client-side scripting - Wikipedia, the free encyclopedia
... different and changing content depending on user input, environmental conditions (such as the time of day), or other variables. Client-side ...

Senior Search Manager - Client Side!!
... strategy insight for senior IT management - resources to understand and leverage information technology. Senior Search Manager - Client Side ...

Account Manager - Client Side - Previous Agency Experience Welcome!!
Computerworld Australia is the leading source of technology news, analysis and tools for IT decision makers, managers and professionals.

Media Sales Executive - Client Side!!
Technology news and reviews for business and home.

PPC Paid Search Manager - CLIENT SIDE
Defining Technology for Australia's IT Leaders. PPC Paid Search Manager - SEM - **CLIENT SIDE** Sydney CBD Location Client side!! SEM/PPC/Paid ...

How Basecamp Next got to be so damn fast without using much client-side UI
When we started working on Basecamp Next last year, we had much internal debate about whether we should evolve the existing code base or rewrite ...

Seven Tips for Pitching From the Client's Side of the Table
I had a chance to sit on the other side of the pitch table. Here is what I learned.

Client-side coding: How to prevent malicious use?
Applications that run on a user-controlled device cannot be perfectly protected.

The client side
... regarding the professionals you seek to assist. Even better if you possess that understanding yourself, having worked on the client side. I'm ...

Ecommerce traffic being hijacked by client side malware
According to new research 15 to 30 percent of eCommerce site visitors are infected with Client Side Injected Malware (CSIM) that causes them ...

Resources last updated: 12/13/2015 7:51:26 AM