.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How do you get a textbox/input or a javascript to postback?

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net

I am using a Yahoo UI dual slider.  The dual slider changes values based on what you slide.  It uses javascript and sends this value back to a Input type="text" textbox. 

I want to be able to do a automatic postback and call the server function "protected void zoom(object sender, EventArgs e)"  each time the slider value changes.

So what I did was:

<asp:TextBox type="text" id="demo_from"  runat="server"
OnTextChanged="Zoom" AutoPostBack="true">

But the problem is, it WILL not fire the server-side event unless I manually click the textbox and press "ENTER".  Then the event will fire (during debug).

So how can I get the event to auto-fire each time the slider value changes?


View Complete Post

More Related Resource Links

Textbox that is enabled by javascript not retained on postback


In my page, I need to enable a text box when user click on check box(checked). I have used javascript for this. It works fine but when there is postback for the page, the textbox becomes disabled again although the check box is checked. But the value in textbox still appears. Is there any method to retain the enabled state for text box on postback other than using hidden values?

Issues with multiline textbox, javascript and IE


Hi All,

i have a requirement to embolden/italicise the selected  text in a textbox. the way it is implemented as is by using a js function which inserts <b> and </b> tags at the start and end of the selected text  for bold, and similarly <i> and </i> tags at the start and end of the selected text  for italics.

here is the code in c# (to add attributes to link buttons)

lkbBold.Attributes.Add("onclick", "AddHTMLTags('" + txtTitle.ClientID + "', 'B'); return false;");
lkbItalic.Attributes.Add("onclick", "AddHTMLTags('" + txtTitle.ClientID + "', 'I'); return false;");

the txtTitle is the id of the text box, which contains the selected text to be emboldend.

and here's the javascript method

function AddHTMLTags(textBoxId, format)
  var textComponent = document.getElementById(textBoxId);
  var selectedText;
  var textToReplace; 
  var content = document.getElementById(textBoxId).value;
  var content1 ;
  var content2 ;
  var newContent; 
      // For IE 
      if (document.selection != undefined)
        var len =  document.selection.createRange().text.length;
        var myrange

Enter the date on the WPF DatePicker input textbox instead

When i type in the date on the date picker and check it on an lostfocus event and i try to read the text or selecteddate its blank?  Am i missing something.  I assumed typing in 5/11/2010 on the input box would either show up on the controls Text or the SelectedDate, but i may be missing something   Thanks

Javascript to update value in Textbox

Hi I have a javascript file, which creates a calendar picker. This file is used through out the application and is a piece of code that I have to use because my .Net application is part of another application which uses this piece of JavaScript code.Anyhow, with the calendar picker I can save the date into a textbox, but the problem that I have is the format. Unfortunately, I cannot change the calendar picker code because this will affect other parts of the application. Therefore, what I am looking to do is to reformat the date on the textbox control. This I can do but only when I use the javascript event onfocus.Now, my question is this, is there away in javascript or with jquery that when a value enters into a textbox that this value is then reformatted to the format I want without postback or clicking on the textbox?Thanks

Problem with JavaScript on Textbox

 I have a textbox which is populated by an external javascript file which I cannot alter without affecting another part of the system. What I would like to do is once this textbox has a value to do something with it. The javascript that I want to use is fine, but it won't automatically when a value has populated it i.e. onchange. It will work when the event is onfocus. Is there away in which I can automatically fire off my javascript event when a value has entered the textbox from another piece of javascript code?  

problem with javascript in multiline textbox

 I am setting Maxlength of a textbox using javascript. Take maxlegth as 100.As we know Enter key is taking two char space. But i want to avoid this. i.e. if i press enter key after 96th char it should allow me to enter four more char where now it is allowing only 98. This is wat i am using  function textboxMultilineMaxNumber(txt,maxLen) { try { if(txt.value.length > (maxLen-1)) return false; } } catch(e){ } }

linebreak in textbox using javascript

I want to assign a textvalue with linebreaks to a textbox control using javascript.I tried (\n):hlResetStyle.Attributes.Add("onclick", "javascript:document.getElementById('" + CSS.ClientID + "').value='#progress{color:#000;width:500px;height:30px;padding:0px;clear:both;}\n\n\n#progress ul{list-style:none;padding:0px;margin: auto;display:block;}';")and tried (<br/>)hlResetStyle.Attributes.Add("onclick", "javascript:document.getElementById('" + CSS.ClientID + "').value='#progress{color:#000;width:500px;height:30px;padding:0px;clear:both;}<br/><br/><br/><br/>#progress ul{list-style:none;padding:0px;margin: auto;display:block;}';")But without luck....How to do it?

Client Javascript runs, but then page errors out when clicking on a control that uses postback

Using this script on a button click <script language="javascript"> function printdiv(printpage) { var headstr = "<html><head><title></title></head><body>"; var footstr = "</body>"; var newstr = document.all.item(printpage).innerHTML; var oldstr = document.body.innerHTML; document.body.innerHTML = headstr + newstr + footstr; window.print(); document.body.innerHTML = oldstr; return false; } </script> After it is done, I can't click on my calendar control.  I was hoping to add somethign that would force a refresh in the script, but nothing I do works. Any thoughts?  Thanks! 

Gridview attribute changed by javascript is lost on postback

I have a gridview control that extends the default gridview.  I have added an attribute called "hiddenSelectedValues" to to the gridview during the "PreRender" event and I have a private variable that points to the value of that attribute. I have some javascript code that modifies the value of this attribute based on the user checking or unchecking checkboxes in the grid.  I have confirmed that the javascript is indeed modifying the value of the "hiddenSelectedValues" attribute by using Firebug to see the change as it happens. However, once a postback occurs, the grid looses the updated value of this attribute and I am unable to reference get the updated value on the server side. How do I keep the value of an attribute changed by javascript on postback?

textbox not writable after partial postback of updatepanel

hi, i got a strange problem. my project was ok before implimenting ajax. i have just implimented ajax in one page only with Tabcontainer and updatepanels only nothing else. almost all controls are devided into different Tabs with respective update panels. mostly it is working ok. but the problem is : 1.   in some controls i am not able to write anything even the control is "Enabled=True" and focus is on the same control after partial postback. 2.   and as soon as i press Tab control goes to Address bar. 3.   some time tab key is also not working.Why ? here some code :<td style="width: 57684px; text-align: left">                                                Inception Date (dd-mm-yyyy)</td>                                            <td style="width: 604px; text-align: left">              &n

javascript for field validation on a textbox...

I'm looking at doing the validation for the email in javascript since we have asp.net 1.1. I can get it to just alert fine, but once I add the return validation it doesn't fire. Me.ImageButton2.Attributes.Add("onclick", "return validation(this);") <script language="JavaScript"> <!-- function validation () { var test=""; test = document.ticketForm.emailAddress.value; if (test == "xyz") { alert(test); return false; // validation failed } --> </script>

Not able to bind textbox with javascript textbox? Why?

I'm trying to use a javascript Date and Time calendar in my Insert and Edit templates in a Detailsview that is bound to SQL Fields. The reason I am trying the javascript date time selector is that I need to have the date and time, the asp.net one is just the date part. I guess my first question is this possible? I tried using it with an asp:textbox on just a plain aspx page and it works like a charm, however when I add it to the detailsview i keep on getting the "Error: Object required"  am I missing a step here?  That and seeing as I'm using a site master page where exactly do I put the:  "<script type="text/javascript" src="datetimepicker_css.js"></script> "   <asp:TemplateField HeaderText="Start Time" SortExpression="StartTS"> <EditItemTemplate>   <asp:TextBox ID="STEditCalendartxt" runat="server" Text='<%# Bind("StartTS") %>'>    </asp:TextBox> <a href="javascript:NewCssCal('STEditCalendartxt','mmddyyyy','arrow',true)"> <img src="images/cal.gif" width="16" height="16" alt="Pick a date"></a>  </EditItemTemplate> Any assistance would be greatly welcomed.

Using HTML5 new input types with .NET TextBox control


Hi here's my problem.


I'm building a iPhone, iPad website I'd like to use the new HTML 5 input types: http://www.w3.org/TR/html-markup/input.number.html so a numeric keyboard will pop.


I'm using a ASP .NET TextBox :

<asp:TextBox ID

how to Input data from textbox to unknown size of array or arraylist?


I am fresh to asp.net. I m using vb to write it. Could someone who is professional guide me?

I want to input data from textbox to "unknown size" array or arraylist, and bind it to gridview.

I have more than 1 data to input. Do i need to use loop to bind?

Thank you for your kind attention and patient.

Can't access dynamicly created textbox in AJAX postback.


I have a script which creates a dynamic textbox (and more) in an AJAX async post back. But when I try to acess the textbox I am told "Object reference not set to an  instance of an object". I have been strugleing with this for a long time and can not get it to work so please help me. This is written in C# .Net 4. The line causing the problem is the very last one where I have tbGameName.Text.Trim()

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class GameInformation_AddUpcomingRelease : System.Web.UI.Page
    protected override void OnInit(EventArgs e)
        string v = this.Request.Params.Get(this.ddlAmountToAdd.UniqueID);

        string[] Regions = { "USA", "Japan", "Europe", "Other" }; //Create a string array of regions.
        string[] Platforms = { "PlayStation 3", "X-Box 360", "Wii", "Computer", "PSP", "Other" }; //Create a string array of platforms

        CreateControlSet(1, Regions, Platforms); //Generate the first Control Set

        if (!string.IsNullOrEmpty(v))
            for (byte i = 2; i <= Convert.ToByte(v); i++)
                //Add a

Delay Postback in Javascript


How to Delay Postback in Asp.net Using Javascript: Please Post Some Sample Code

I have a Button Need to Show a Timer Of 10 Seconds and Then Postback. This will happen on Button CLick

So How can i Accomplished that ??

Textbox in Gridvew Control not saving keyed in input


 Hi, Can anyone help with this;

I have a textbox in a item template field in a gridview control and a button field as a regular column

See columns below:

<tr valign<

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend