This is a migrated thread and some comments may be shown as answers.

Enable Button inside RadWindow

5 Answers 213 Views
Window
This is a migrated thread and some comments may be shown as answers.
Soumya
Top achievements
Rank 1
Soumya asked on 18 Jul 2012, 11:18 AM
I have an aspx page with a button which is disabled.
How to enable the button,only when it is poping up as a RadWindow from a parent page?

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Jul 2012, 10:48 AM
Hello,

Try the following javascript to enable button on opening window.
aspx:
<asp:Button ID="Button1" runat="server" Text="Button" Enabled="false" />
 <telerik:RadWindow ID="RadWindow1" OnClientShow="OnClientShow" OnClientClose="OnClientClose" runat="server"></telerik:RadWindow>

JS:
function OnClientShow() {
       debugger;
       var btn = document.getElementById("<%= Button1.ClientID %>");
       btn.disabled = false;
   }
   function OnClientClose() {
    var btn = document.getElementById("<%= Button1.ClientID %>");
   btn.disabled = true;
   }

Thanks,
Shinu.
0
Soumya
Top achievements
Rank 1
answered on 23 Jul 2012, 10:42 AM
Hi Shinu,
I was not able to make it work.
I am calling radwindow from parent aspx page as below
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        <Windows>
      <telerik:RadWindow ID="Enqdialog" Title="Enquiry" runat="server" Height="550px" Width="1200px"
                Left="200px" Behaviors="Close" Modal="true" />      
        </Windows>
</telerik:RadWindowManager>

In the aspx page(which comes as radwindow),I have the below code
Here I am passing data from the radwindow to the parent page using the function CloseAndReload(),which is called from the code behind on button click.I need to make this button disabled
on closing and enabled on opening radwindow.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
  <script type="text/javascript">
      function GetRadWindow() {
          var oWindow = null;
          if (window.radWindow) oWindow = window.radWindow; 
          else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 
 
          return oWindow;
      }
      function CloseAndReload() {
          var oWnd = GetRadWindow();
          oWnd.BrowserWindow.location.reload();
          oWnd.close();
      
    </script>
    </telerik:RadCodeBlock>

<asp:Button ID="btnGetValues" Text="Register" runat="server" 
            onclick="btnGetValues_Click" >   

aspx.cs
protected void btnGetValues_Click(object sender, EventArgs e)
        {
             //
            //
            if (result == false)
            {               
                ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "CloseAndReload();", true);              
            }
   }

I am not getting the enabled or disabled property for the button inside javascript function.I think Iam missing something.

Thanks in advance,
soumya
0
Shinu
Top achievements
Rank 2
answered on 24 Jul 2012, 12:47 PM
Hi Soumya,

If the page is not popping as a radwindow, you can disable the button on onclick event of Button2. Try the code snippets below.

ASPX:
<asp:Button ID="Button1"  runat="server"  />
<asp:Button ID="Button2" CssClass="buttons" runat="server" onclick="Button2_Click"   />
<asp:HiddenField ID="HiddenField1" runat="server" />

CSS:
<style type="text/css">
.buttons
{
 display:none;
}
</style>

Javascript:
function pageLoad()
{
 var button2 = document.getElementById("Button2");
 var HiddenField = document.getElementById("HiddenField1");
 if ((!window.frameElement) && (HiddenField.value != "1")) // Check whether popping From RadWindow.
 {
  button2.click();
 }
}

C#:
protected void Button2_Click(object sender, EventArgs e)
{
 Button1.Enabled = false;
 HiddenField1.Value = "1";
}

Thanks,
Shinu.
0
Soumya
Top achievements
Rank 1
answered on 29 Jul 2012, 07:56 AM
Thanks Shinu.
It is working

Thanks,
Soumya
0
Soumya
Top achievements
Rank 1
answered on 30 Jul 2012, 10:10 AM
Hi shinu,
One more question regarding this.
I am trying to disable a button on the comand item of Radgrid.
I am using the below code for disabling the button when it is not poping as radwindow .
aspx:
function pageLoad() {
       var button2 = document.getElementById("<%=Button2.ClientID%>");
       var HiddenField = document.getElementById("<%=HiddenField1.ClientID%>");        
       if ((!window.frameElement) && (HiddenField.value != "1")) // Check whether popping From RadWindow.
       {
           button2.click();
       }
   }
aspx.cs:
protected void Button2_Click(object sender, EventArgs e)
       {
           GridCommandItem commandItem1 = (GridCommandItem)gvPhoneInq.MasterTableView.GetItems(GridItemType.CommandItem)[0];
           Button btn = (Button)commandItem1.FindControl("btnRegister");
           btn.Enabled = false;
           HiddenField1.Value = "1";
       }

On page load,the button is disabled and further on postback,it is not disabled as the Button2_Click event is not triggered due to hidden field value(hope so).
How can I reset the value of hidden field.Setting HiddenField1.Value = string.Empty; in the page load is not working.

Thanks,
Soumya
Tags
Window
Asked by
Soumya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Soumya
Top achievements
Rank 1
Share this question
or