Trying to get Button to add Text in TextBox

Hey all. I'm trying to place text (HTML codes) in a text box based off of a clicked button without a refresh of the page. 

Example: 3 Buttons for Bold, Italic, Underline and a TextBox. When you click on a button, it will enter either <b> <i> or <u> in the textbox. I have acheved this part but it appears a page refresh has occured everytime you click a button. To make matters worse, the text box is at the bottom of the webpage, and when the refresh occurs you're taken back to the top of the page. You must scroll down to get back to the TextBox you're working with. Is this considered PostBack? If so how can I just click one of the Buttons and have it immediately spit the text/code into the textbox with no page refresh, postback or scrolling needed?
Thanks,
Anthony
0
homeskillet13
9/14/2004 6:07:16 PM
asp.net.client-side 24353 articles. 1 followers. Follow

2 Replies
661 Views

Similar Articles

[PageSpeed] 23

Consider using client side JavaScript and client side button ( not the asp:button ).  This will eliminate the postback.

An Example ....
<input type="button" value="B" onclick="addBold()"></input>

<script>
function addBold()
{
textbox = document.getElementByID("<the textBox.ID>" ) ; // This fetches the TextBox from DOM.
textbox.value = ""+textbox.value+"" ; // encapsulate the original textbox value.
}
</script>

I am assuming each button affects the same textbox. I would not use "server side" buttons because there function can and should be done on the client side. The TextBox however should be server side - assuming you are going to do something with it's contents such as send an email and that is the tricky part since ASP.net may change the textboxID when rendering to the client - especially when master pages are involved.


2 wrongs don't make a right - but three lefts do
0
echo88
9/14/2004 7:48:47 PM
That answers a lot. Plus it lets me know to get some Javascript under my belt! Thanks for your help.

Anthony
0
homeskillet13
9/14/2004 8:58:02 PM
Reply:

Similar Artilces:

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

Getting Textbox Watermark Text in client side javascript
Can somebody tell me how I can go about grabbing the Text value of a TextBoxWatermark control from client side javascript?  I need to make a comparison/validation if a text box has been filled out (non-blank) and of course the watermark fills in the text value of the text box when grabbing the property (of the text box) per javascript? So, I need to somehow grab the text from the watermark in javascript and then compare to the text box contents to see if the text in the textbox is the water mark text or not.  Any information would be greatly appreciated.  Thanks!  Th...

execute client side java popup on save.. using a button onCommand tried sender but get error
I want to execute the bold and underlined popup clinet side java on save or error.. the sender is an oncommand="save" on a buttonHow would I execute that?       error i get = System.MissingMemberException: Public member 'RegisterStartupScript' on type 'Button' not found.  Thanks  Protected Sub save(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) 'find the control from the repeaterDim b As Button = senderDim varMsgID As String = CType(b.Parent.FindControl("hiddenfield1"), Hid...

length or trim ? how can i get textbox.text as text that publichouse to textbox.text as text that public ?
hello friends length or trim ? how can i get textbox.text as text that publichouse to textbox.text as text that public ? second example is ..... textbox1.text is greenhouse.. i want to get green from textbox.text cheer Mark as me if my question or my answer can be helpful for you :) Hi,you can always perform a Trim to a retrieved string to delete the leading and trailing space characters. For your second example where you want to gt a part of the retrieved string you can use the SubString method of the String class.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workar...

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

the client side function insertAdjacentHTML adds the text then the text disapears right way (it blinks)
Here the script I put in my page_load: string scriptString="<Script Language=JavaScript> function fnAdd() {";scriptString += "document.body.insertAdjacentHTML('BeforeEnd','<P>' + document.getElementById('oText').value + '<P>');}<";scriptString+="/";scriptString+="script>";this.RegisterClientScriptBlock("fnAddit",scriptString);this.Button1.Attributes.Add("onClick","fnAdd()");Can u tell me pls how I can make the text of 'oText' still on the page instead of ...

Getting the text from a button to put into a textbox
All, I'm trying to get text from a button that is being populated from the database. The code I have is able to capture the text but it becomes "Nothing" when it ends at End IF. Am I doing something wrong? Protected Sub txtID_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)Dim txt As TextBox = CType(sender, TextBox)Dim detv As DetailsView = CType(txt.NamingContainer, DetailsView)Dim row As GridViewRowDim btn As New ButtonDim strText As String = btn.TextIf detv.DataItem Is Nothing ThenFor Each row In GridView1.Rowsbtn = CType(row.FindControl("Button1"...

How to validate text in a textbox on CLIENT SIDE?
 HiI have validate a TextBox on WebForm, such that the user is able to enter only numbers in the TextBox, on the Client Side, i.e. without posting back to the server.I have user CustomValidator and a JavaScript function to validate the number in the TextBox to be divisible by, say 5, reading an example from a book.What function do I use to check whether the text in the TextBox is numeric or not? Or there anything like SendKeys or KeyPress.Handle?Thanks in advance.  Kumar Kush You can do this... <asp:TextBox ID="txtNumbers" runat="server" onkeypress="r...

Get textbox value in client side
My problem is that in my ascx file i have a textbox & a input buttom with a javascript function that will validate the textbox: .... <script lang="javascript"> function Test() { if (document.all.txt1.value == "") { alert(); return; } } </script> .... <asp:textbox id="txt1" runat="Server"></textbox> <input type=button id="cmd1" onclick="javascript:Test();" value="Add"> .... But the function don't work, because the textbox control isn't...

dynamic add a few textBox by Javascript (client side)
VS.NET 2003, Framework 1.0 , ASp.net (VB) , SQL 2005 i'm having a problem is ...i 'm using js to add a few textbox dynamically when i clicked  AddNewRow()so when i wanna use (server side) VB codebehind to get the txtbox value....it look like canot get it.... bcoz the txtbox is like not defined in WEB page.    HOw ?????? helps thx Hello, I am afraid you could not access the TextBox from Server side when you create the TextBox from client side. The Server knows nothing about the TextBox Control. My suggestion is if you really want to avoid postback when you ad...

get the changed value of a text box
Hello everybody! I have this in the server side: <asp:textbox id="TEscala" runat="server"></asp:textbox> <asp:imagebutton id="BIrEscala" runtat="server" imageurl="images/irmapa.gif"> </asp:imagebutton> And i want to do this: Private Sub BIrEscala_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles BIrEscala.Click Dim xx As String xx = Tescala.value End Sub The problem is that "xx" doesn´t get the new value written in the ...

Getting Value from Client-side InputBox to .net variable
hi, im doing a login page for our timekeeping. Since there's no msgbox available on asp.net, im doing it dynamically via javascript. How do i Get the value frm a dynamically written javascript (such as inputbox) to a .net variable? here's the logic of my program, user logs in hits the button and sub-routine Login will be fired, if user is late -- call Check_Late Sub, this is whre the client-side script was built -- then after that i wanted to be able to get the value from an inputbox. '// if button login clicked Sub Login(Sender As Object, E As EventArgs) .......

How to provide textbox text formatting toolbar at client side?
Hi to all, I am new to web development. I required to provide the facility to client  so that he can format the text of text box like bold, italics, fontsize, colors etc at client side.But i could not found any option to provide formatting toolbar with textbox. If Is it possible then please tell me how it can be done. Regards,Sandeep Soni Sandeep  You need to use some thing like:Free Text box from http://freetextbox.com/default.aspx Don't forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your...

trying to get the value of a textbox.text before a post back
ASP.NET 2.0. VB.Net  I am trying to get the value of this textbox before postback<asp:TextBox ID="Notes" runat="server" TextMode="MultiLine" Rows="6" Columns="90"></asp:TextBox>Once I get the value I would like to update a DataSet before postback 'Update Email Message Dim UpdateEmail3MessageAdapter As New Email_Temp3TableAdapters.Email_Temp3TableAdapter Dim UpdateEmail3Message As Email_Temp3.Email_Temp3DataTable = UpdateEmail3MessageAdapter.GetDataEmail_Temp3 For Each UpdateEmail3MessageRow A...

Web resources about - Trying to get Button to add Text in TextBox - asp.net.client-side

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

www.asianewsphoto.com 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 www.textnovel.com 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: 12/9/2015 11:13:38 PM