How to change the TEXTBOX text without doing a post back?

How to change the TEXTBOX text without doing a post back? The textbox is <asp:textbox> , i mean web form based textbox not the html one.

I wanna use this method to insert html tags cuz i didn't find free richtextbox or something with the same function.
ASP.NET Hosting (HostingFest)
11/24/2004 7:51:37 PM 93655 articles. 5 followers. Follow

6 Replies

Similar Articles

[PageSpeed] 7

if your not posting back, then your at the client so you need to use javascript.

the <asp:textbox> renders as a standard input control
Mike Banavige

Need a site code sample in a different language? Try converting it with:
11/24/2004 9:32:49 PM

Edited by SomeNewKid. Please post code between <code> and </code> tags.

hi you can do it by using java script.
Here is the simple example in which I am changing the text of a asp:Textbox control by using a java script.

<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="" name="vs_targetSchema">
<script language="javascript">

function test()
var text = document.getElementById("TextBox1");

text.value = 'test';

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" encType="multipart/form-data" runat="server">

<asp:TextBox id="TextBox1" style="Z-INDEX: 104; LEFT: 152px; POSITION: absolute; TOP: 96px" runat="server"></asp:TextBox>

<INPUT style="Z-INDEX: 105; LEFT: 240px; POSITION: absolute; TOP: 360px" type="button"
value="Button" onclick = "test();" >

"When you reach for the stars, you may not quite get them, but you won't come up with a handful of mud either"
11/25/2004 9:39:35 AM
Hi !!!

this might be a silly question but i am new for web development
Is java script is cleint side code?? I mean is it always cleint side or i can do it in server side?
If if yes, What is the benefit of using java script in server side?

Thank you

Fadil Alnassar | FREE Nodil Tab Control
11/25/2004 10:05:24 AM

There is no benefit of writing javascript code on the server side.
It is just that ASP.NET allows you to do the same .
It will complie all HTML output at Runtime , and since its a one time compile shall work just as same as writing in js file.
Hmm the disadvantage tho is that everytime you wish to change client side code, written on the server side it shall require a rebuild.
11/25/2004 11:19:57 AM
You dont write javascript on the server side. Sometimes we would like the compiler to emit some custom javascript code to the html, there we write it to the HttpResponse. But strictly speaking, its simply strings, not javascript when it comes to the compiler. for example, when you write the following

Reponse.Write("<script language='javascript'> function something(){//do whatever}</script>");
This will be written to the browser as javascript. But as you can see its only strings for the c# compiler. So to summarize, javascript is only client side
Kumar Reddi
11/25/2004 1:00:14 PM
Thank you, it is clear now!!!!1

Fadil Alnassar | FREE Nodil Tab Control
11/25/2004 1:22:13 PM

Similar Artilces:

How to change the value of textbox without posting page back to the server
Hello everyone, I have a simple form with 3 textboxes namely txtNumber1, txtNumber2, txtTotal. The txtTotal will display the sum of txtNumber1 and txtNumber2. I'd like when the user enter a number either in txtNumber1 or txtNumber2 the txtTotal will automatically update its value without posting page back to the server. Do I need to utilize Ajax to accomplish it? Thanks for reading.   There are couple of options you can use: 1] Use Java Script to Populate your txtTotal on change of text in txtNumber1  / txtNumber2 2] You can use AJAX, by putting your cont...

Help! javascript change text in textbox lost after posting back?
Hi there, I am using VS 2005. I have a dropdownlist and a hidden textbox on a page. Hidden textbox is enabled and enableViewstate = true. When selecteditem in dropdownlist changes, I change the value in textbox using javascript. On client side, it works fine. But when postback, changed value in textbox is lost. It gets the original value. Even I set the textbox visible == true. It still doesn't work. I could not figure out want goes wrong. can anybody help? thanks, Kai   Do you by chance not have the runat="server" attribute on the TextBox? You also cannot use the server-side V...

can i use a calendar picker control in my form without it posting back the page when i pick or change the date?
can i use a calendar picker control in my form without it posting back the page when i pick or change the date? First: Then Mike [MVP - ASP/ASP.NET]My site jolyon:can i use a calendar picker control in my form without it posting back the page when i pick or change the date?  Based on my understanding, you can try to use JavaScript to solve your problem.Also I write a demo for your reference only; Please look at the part of "bold";CalendarDemo.aspx: <%@ Pa...

Web TextBox Find out where currently selected text is and change the text itself.
Ive been looking over the system.web.ui.webcontrols.textbox class recently and there seems to be a lack of functionality concerning getting the position (start/end) of the selected text. The selectedtext property only seems to exist on windows.forms textboxes. Im trying to create some rich textbox type tools but I cant figure out how to get the position of the text. Someone suggested using javascript document.createRange and document.getSelection but I dont see how to apply the javascript methods to server side textboxes. Any suggestions anyone? The selection of the text occu...

How to post back without really posting back?
I call a web service to get a value to update a textbox in response to a client side (javascript) event. Once I have that value I also need to update a RangeValidator's MaximumValue property. There doesn't seem to be a way to do this from the client side and I really don't want to do a full postback just to update this property. Can someone suggest an alternative? Thanks ... Ed   You can do everything with JavaScript. After the textbox is updated through your web service, you can use another javascript function to validate the range of the input. Use the onchange fu...

Changing Web Form Designer Generated Code
I am using to create an application. In one of my "pages", I have the SQL Select Command that VS generated for me, and I have added a couple of lines to pass through a querystring variable into the query. It works great, however keeps deleting my additions and reverting back to the original query. Any way to prevent this? Don't put your changes in that method. VS.NET overwrites that method whenever it wants to. You can create your own method, and make a call to that method right after the base.OnInit call in (I think, I don't have ASP.NET at work si...

Changing "Web Form Designer Generated Code" and it Changes back!
I created a SQL connection using's built in tools for doing so. I'm calling a stored procedure to which I am trying to pass a variable (the contents of a querystring). I have the code for this written in the SQLSelectCommand1 area, but the problem is keeps changing the code back to the way it wrote it. My way works, VS doesn't, so I have to keep pasting my code changes back to the .vb file. Is there any way to make these changes stick?...

Could PB .NET Web Form POST security Information to others web page??
This is a multi-part message in MIME format. ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi,=20 Have anyone came across the requesion to POST security informations from = PB .NET web form web page to other web site?? I have tried many datys, Could any kind man give me some suggessions?? thanks & Best regards Leon ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML P...

Check if the text box "text" has changed (RePost from web forms forum)
Greetings! How can i know if the "text" inside of a text box has changed? For example, I currently have this: if (txtMU.TextChanged()) { } But this does not work. The other idea I had was to assign the existing value of the text box to a string and then when the user click the save button I can create a conditional statement to compare the original string with the new string. However, I would like something more effective as I have like 12 text boxes to compare. Thanks, EduardoThanks,Please Mark this post as answered if it was helpful. Here is the easiest way that I have ...

hei guys, i need help on my application, i'm using C#.NET as front-ed and SQL as back-end, aside from a datagrid, i want to display my data using textboxes and not a datagrid, i can do it using Visual Basic 6 but since i'm a newbee at C#.NET i don't know how to do it, specially the codes, can anyone help me with it? thank you in advance! If you are doing windows development, i would suggest using 'DataForm wizard' (Use Solution Explorer-->Rightclick project-->Add new Item-->New DataForm). It will guide you through steps. If you are doing web apps. Use quickstart to learn them. h...

Web form debugging
Hi, This is SOS call, since I have no idea what happend, but my web page is not working any more though I didn't change a thing. I have a web page, containing datagrid, dataset, and listbox. The user chooses an item from the listbox, push the button, and get the relevant records in the datagrid.  I added another feature: "quick search" containing textbox and another button, and when the user type something in the textbox and push the button, the datagrid being populated from the new search algorithm instead of the listbox. Every thing was working perfect, till I changed something, a...

Prevent browser refreshes from posting back an already-posted-back form?
HiI have a formview in insert mode for inserting items into a gridview.  Each item is some description text, a price, and a quantity.  I'm using SqlDataSource controls while I learn about the New Way of Doing Things.If I insert an item, and then refresh the now-posted-back page in my browser, the same item gets inserted again.  I would like to prevent this, ideally without response.redirecting on FormView.ItemInserted every time a new item is inserted.  I don't think it'd be a question of clearing the inputs and validating for data, would it?  I mean, an F5 will repo...

Implementing .Net Form into an web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Changing the value of a textbox without submitting the form
Hi there, I have 3 buttons on a form. the first is for submitt the form and the other 2 is for changing the values of a textbox without submitting the form. When I click on this two buttons the form is submitted and the value of the textboxs are changed. Can I change the values of the textbox without submitting the form. Thanks Use html buttons and javascript. <input type="button" onclick="javascriptThatChangesTextBoxes()" value="Display alert box"> Jigar Desai-----------------------Do not forget to "Mark as Answer" on the ...

Web resources about - How to change the TEXTBOX text without doing a post back? -

Aqua (user interface) - Wikipedia, the free encyclopedia
Aqua is the GUI and primary visual theme of Apple Inc. 's OS X operating system . It is based around the theme of water, as its name suggests, ...

Wikipedia:Sockpuppet investigations - Wikipedia, the free encyclopedia
WP:RFCU redirects here. You may be looking for Wikipedia:Requests for comment/User conduct ( WP:RFC/U ), CheckUser policy ( Wikipedia:CheckUser ...

Help - is a social service . Users can post short(140 character) status messages which are broadcast totheir friends and colleagues on the ...

City of Whitehorse, YT : Contact
Employment - Bylaws - Document Library - FAQ - Contact Us Search Query Textbox Home Home About Whitehorse Notify Me Contact Us Employee Links ... Help
Help for uploading pictures Noun explanation Group pictures: a basic unit which stands for a piece of news photo in system; include: information ...

Metamorphose: All-In-One File/Folder Renamer For Windows, Mac & Linux
Previously, we’ve reviewed many batch file-renaming applications like ReNamer (read review), NameChanger (read review), File Grinder (read review) ...

How to build a Twitter extension for Chrome
Ars takes a close look at the Chrome Web browser's new extension system. In …

ASUSTeK Computer Inc. -Support- RSS
... RSS Service, please follow the instructions below. STEP 1. Select the product to subscribe. STEP 2. The RSS link will be shown on the Textbox ...

authonomy writers and readers - Daniel Escurel Occeno's profile - authonomy writing community
... of the Point Guard”. It is entered in writing contest.In the TEXTNOVEL website simply type in “Lee Chon” in the textbox search ...

Baseball Prospectus
Forgot Your Password? Enter your username in the textbox below. Username: If you don't remember your username, please contact Customer Service ...

Resources last updated: 11/21/2015 3:07:56 PM