FreeTextBox

The no. 1 free ASP.NET HTML Editor.
Welcome to FreeTextBox Sign in | Join | Help
in Search

Adding JavaScript to control... not finding documentation... am I blind?

Last post 05-13-2008, 9:34 AM by Nikunjganatra007. 5 replies.
Sort Posts: Previous Next
  •  04-28-2006, 4:20 PM 6372

    Adding JavaScript to control... not finding documentation... am I blind?

    I have a script already implemented in my control adding the attributes to a textbox control (we will call it txtContent), here is example to how this is done in the code behind:

    txtContent.Attributes.Add("eventHere", "script contents for event go here");

    I want to implement FTB and still have access to my incorporated script that is part of the application I am developing for work. 

    I am not finding any method to do so... please help... if it is in the documentation just give me a hint and I'll find it myself.

    Ryan

  •  04-29-2006, 11:38 AM 6382 in reply to 6372

    Re: Adding JavaScript to control... not finding documentation... am I blind?

    FreeTextBox is not a standard HTML object so the standard JAvaScript event code does not apply. There is a ASP.NET property called "ClientSideTextChanged" that you can code against. If that's not what you're looking for, let me know what event you're trying to access and I'll try to help you use it.

    JD

    John Dyer
    freetextbox.com
  •  05-01-2006, 10:07 AM 6403 in reply to 6382

    Re: Adding JavaScript to control... not finding documentation... am I blind?

    I'm trying to fire OnKeyUp and OnKeyDown for the following script, which is used frequently to allow the user to monitor the characters left in a textbox:

    <script language="javascript" type="text/javascript">

    <!-- Begin

    function textCounter(field,cntfield,maxlimit) {

    if (field.value.length > maxlimit) // trim if length is too big

    field.value = field.value.substring(0, maxlimit);

    // update counter

    else

    cntfield.value = maxlimit - field.value.length;

    }

    // End -->

    </script>

    Typically, I would set the control (named txtControl) javascript events inside the code behind as follows (this is using a master  page):

    txtContent.Attributes.Add("onKeyDown", "textCounter(document.aspnetForm.ctl00_ContentPlaceHolder1_txtContent,document.aspnetForm.ctl00_ContentPlaceHolder1_curRemaining," + intMaxValue + ")");

    txtContent.Attributes.Add("onKeyUp", "textCounter(document.aspnetForm.ctl00_ContentPlaceHolder1_txtContent,document.aspnetForm.ctl00_ContentPlaceHolder1_curRemaining," + intMaxValue + ")");

    Trying the ClientSideTextChanged method as you suggested did not work.  The script did not give any errors, but the script also did not work as it was supposed to... nothing happened when changing text in the textbox. 

    The HTML being created for the text box contains no javascript events, which to my knowledge is neccessary to achieve what I want:

    <textarea id="ctl00_ContentPlaceHolder1_txtContent" name="ctl00_ContentPlaceHolder1_txtContent" disabled="disabled" style="padding: 0px; width:450px; height: 250px;" class="ctl00_ContentPlaceHolder1_txtContent_HtmlBox"></textarea>

    I really love FTB, I appreciate you developing it and supporting it in your own time... thank you!

    Ryan

  •  05-08-2006, 8:48 AM 6472 in reply to 6403

    Re: Adding JavaScript to control... not finding documentation... am I blind?

    The only property FTB has for JavaScript is TextChanged. Here's an example of what you can do:

    <FTB:FreeTextBox id="FreeTextBox1"
        ClientSideTextChanged="textChanged"
        runat="Server"
        />

    <script type="text/javascript">
    function textChanged(ftb) {
        var html = ftb.GetHtml();
       
        ftb.SetHtml('new HTML');
    }
    </script>  

    John Dyer
    freetextbox.com
  •  10-22-2006, 3:08 AM 7439 in reply to 6472

    Re: Adding JavaScript to control... not finding documentation... am I blind?

    sadasdsadsadsadsadasdas

    dsadasdsadsadsadasd

    sadsadasdas

    dsadasdsadsadas

    dsadsdasdasdsa

    sadasdsadsadsadsadasdas

    dsadasdsadsadsadasd

    sadsadasdas

    dsadasdsadsadas

    dsadsdasdasdsa

  •  05-13-2008, 9:34 AM 9148 in reply to 6472

    Re: Adding JavaScript to control... not finding documentation... am I blind?

    how can I use Textchange event.
    I want to filter each word Entered in free text box.
    Plz help me ... how can I achive this.
    is there any keydown or key press event....?
    My free text box Text change does n't work!

View as RSS news feed in XML
www.freetextbox.com