Calling Radprompt from code behind with RadAjaxManager

7 posts, 0 answers
  1. cheekl
    cheekl avatar
    55 posts
    Member since:
    Jul 2012

    Posted 03 Jul 2011 Link to this post

    I have a web form with 2 radbutton. Approve and Reject. When Reject button is clicked. I would like to pop up radprompt to capture reject reason and update the reason via stored proc from code behind.
    How can I capture the reason and using it from code behind?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2011 Link to this post

    Hello Cheekl,

    Check out the following code library submission which explains how to call a radalert from codebehind. You can try the same approach to achieve your scenario.
    Calling radalert from codebehind (all versions of RadWindow).

    From the version 2011.1.315 the predefined dialogs (radalert, radconfirm and radprompt) can be called by using the new server methods RadAlert, RadConfirm and RadPrompt of the RadWindowManager.
    Check out the following demo for more on this.
    Window / Alert, Prompt, Confirm.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. cheekl
    cheekl avatar
    55 posts
    Member since:
    Jul 2012

    Posted 04 Jul 2011 Link to this post

    Thanks for the help. I manage to call up the radprompt and trigger the callback function with the code behind
        protected void btnReject_Click(object sender, EventArgs e)
        {
            try
            {
                RadAjaxManager1.ResponseScripts.Add(@"radprompt('Reject reason', promptCallBackFn, 330, 160, null, 'Reject', '')");
            }


    However in the promptCallBackFn, I am trying to assign the value return to a asp:label and the object is null
          function promptCallBackFn(args)
          {
              var lbl = $find("<%=lblRejectReason.ClientID %>");
              lbl.text = args;          
          }      

    I believe it is something to do with Ajax where the control is not loaded, how can I overcome this?
  5. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 07 Jul 2011 Link to this post

    Hi Cheekl,

    You should use $get() to get reference to the label client-side object. The $find() method is used only for script controls/components.

    http://msdn.microsoft.com/en-us/library/bb397717.aspx
    http://msdn.microsoft.com/en-us/library/bb397441%28v=VS.100%29.aspx

    Best wishes,
    Iana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  6. cheekl
    cheekl avatar
    55 posts
    Member since:
    Jul 2012

    Posted 07 Jul 2011 Link to this post

    I still get a null value from $get

          function promptCallBackFn(args)
          {
              var lbl = $get("lblPromptValue");
              lbl.text = args;          
          }

    lblPromptValue is a hidden label.
    <asp:Label ID="lblPromptValue" runat="server" Text="" Visible="false"></asp:Label>

  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 08 Jul 2011 Link to this post

    Hello Cheekl,

    What if you change the code like this:
    function promptCallBackFn(args)
     {
         var lbl = $get("<%= lblPromptValue.ClientID %>");
         lbl.innerHTML = args;         
     }


    Best wishes,
    Iana
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  8. cheekl
    cheekl avatar
    55 posts
    Member since:
    Jul 2012

    Posted 13 Jul 2011 Link to this post

    I found the problem. It is because I set lblPromptValue visible = false.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017