RadTextBox ClientEvent Problem

5 posts, 0 answers
  1. Alessandro
    Alessandro avatar
    20 posts
    Member since:
    Sep 2011

    Posted 02 Nov 2011 Link to this post

    Hi,

    I've got a problem with the ClientEvents-OnFocus of RadTextBox.
    The scenario is: 
    In the RadTextBox I've a text with a ForeColor, when the user click in the textbox (ClientEvents OnFocus) a javascript function delete the text and change the ForeColor of the textbox, but when I test the page the browser notify me that there's an error in the page. The error is with the registration of the js call on the page:
     

    <

     

     

    telerik:RadTextBox ID="txtComuneBene" runat="server" Width="350px" AutoPostBack="true" ClientEvents-OnFocus="javascript:setControlFocus('txtComuneBene');">

     

     

     

    </telerik:RadTextBox>
    I also tried with :

     

    <telerik:RadTextBox ID="txtComuneBene" runat="server" Width="350px" ClientEvents-OnFocus="javascript:setControlFocus('txtComuneBene');">

     

     

     

    </telerik:RadTextBox>
    and

     

    <telerik:RadTextBox ID="txtComuneBene" runat="server" Width="350px" ClientEvents-OnFocus="setControlFocus('txtComuneBene');">

     

     

     

     

     

     

     

    </telerik:RadTextBox>

    and

    <telerik:RadTextBox ID="txtComuneBene" runat="server" Width="350px" ClientEvents-OnFocus="setControlFocus('txtComuneBene')">

     

     

     

     

     

     

     

    </telerik:RadTextBox>

     

     

     

    and finally I try with a js alert to test if I write something wrong but the result is always the same.

    <telerik:RadTextBox ID="txtComuneBene" runat="server" Width="350px" ClientEvents-OnFocus="alert('test alert');">

     

     

     

    </telerik:RadTextBox>

     
    a js error with this message :
    Message: Expected '}'

    And this is the ajax registration ( the problem is the italic style text):
    Sys.Application.add_init(

     

    function() {

     

    $create(Telerik.Web.UI.RadTextBox, {

     

    "_focused":false,"_postBackEventReferenceScript":"setTimeout(\"__doPostBack(\\\u0027ctl00$MainContent$ucRichiestaServizio$txtComuneBene\\\u0027,\\\u0027\\\u0027)\", 0)","_skin":"Default","clientStateFieldID":"ctl00_MainContent_ucRichiestaServizio_txtComuneBene_ClientState","enabled":true,"styles":{HoveredStyle: ["width:350px;", "riTextBox riHover"],InvalidStyle: ["width:350px;", "riTextBox riError"],DisabledStyle: ["width:350px;", "riTextBox riDisabled"],FocusedStyle: ["width:350px;", "riTextBox riFocused"],EmptyMessageStyle: ["width:350px;", "riTextBox riEmpty"],ReadOnlyStyle: ["width:350px;", "riTextBox riRead"],EnabledStyle: ["width:350px;", "riTextBox riEnabled"]}}, {"focus":javascript:setControlFocus('txtComuneBene');}, null, $get("ctl00_MainContent_ucRichiestaServizio_txtComuneBene"));

     

    });



    any ideas?

    another question :

    I've got a page with a RadWindowManager that shows a confirm window, if I click on the "Ok" button the page is refreshed with a complete postback, is there a way to avoid this complete postback? I register in the RadAjaxManager that the RadWindowManager has to refresh a panel inside the page with the RadAjaxLoadingPanel that I have in the page.

    thanks in advance,
    regards
    Alessandro
  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 02 Nov 2011 Link to this post

    Hello Alessandro,

    To attach handler for the Client Events of any RadControl, you should only set the name of the javascript function to the respective property. Then when the event is fired, you will receive two arguments, sender and eventArgs. The sender is the client-side object of the respective control fired the event and eventArgs has different properties for each event. You can find more in our documentation.
    Regarding RadTextBox: Try modifying your code as below:
    <telerik:RadTextBox ID="txtComuneBene" runat="server" Width="350px" ClientEvents-OnFocus="setControlFocus">
    </telerik:RadTextBox>

    Refer to the following resources for more information:
    http://www.telerik.com/help/aspnet-ajax/input-client-side-onfocus.html
    http://demos.telerik.com/aspnet-ajax/input/examples/programming/clientside/onerror/defaultcs.aspx

    Best wishes,
    Iana Tsolova
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. Alessandro
    Alessandro avatar
    20 posts
    Member since:
    Sep 2011

    Posted 02 Nov 2011 Link to this post

    thanks a lot, your advice was very useful.

    And for the other question?
    I've got a page with a RadWindowManager that shows a confirm window, if I click on the "Ok" button the page is refreshed with a complete postback, is there a way to avoid this complete postback? I register in the RadAjaxManager that the RadWindowManager has to refresh a panel inside the page with the RadAjaxLoadingPanel that I have in the page.


    Alessandro
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 02 Nov 2011 Link to this post

    Hello Alessandro,

    If you are using radconfirm from client side, there wont be any postback. You can see the behavior in the following demo.
    Window / Alert, Prompt, Confirm

    Thanks,
    Princy.
  5. Alessandro
    Alessandro avatar
    20 posts
    Member since:
    Sep 2011

    Posted 02 Nov 2011 Link to this post

    Hello,

    I have 3 radio button in an asp:panel.
    I'm using the RadWindowManager from client and the RadScriptManager to register the script that shows the window from the radiobutton click handler. So when the user click on one radio button, (if some condition are verified) in the click event handler i use this this workaround to show the window:

    RadAjaxManager.ResponseScripts.Add(

     

    "showAlertGeneral('Informazione','" + GetLocalResourceObject("InformazioneRichiestaXL").ToString() + "','400px','149px');")

     

    the js showAlertGeneral function is :
    function showAlertGeneral(title, message, width, height){

     

        radalert(message, width, height, title, confirmCallBackFnGeneral);
    }

     

    function

     

     

    confirmCallBackFnGeneral(arg) {

     

    __doPostBack(

     

    'ConfirmCallBack', arg);

     

    }

    and in the page_load (before I check "if Not Me.IsPostBack" ) I check if  the __EVENTTARGET is equal to "ConfirmCallBack"

     

     

     

     

     to call another sub in the code to reset the selected radio button to the previous.

    In the RadAjaxManager I set that the RadAjaxLoadingpanel, after radio button click, has to refresh only the containing panel of the radio buttons.


    thanks in advance

    Alessandro

     

Back to Top