Cannot get RadWindow to open from codebehind

2 posts, 0 answers
  1. ChuckRock
    ChuckRock avatar
    38 posts
    Member since:
    Jul 2006

    Posted 06 Jan 2014 Link to this post

    Hi,

    I've been trying to get a modal RadWindow to open upon clicking on a button after the code-behind has executed.
    I have tried various suggestions posted on this forum, but none seem to work.  

    I have boiled down my problem page to just the components necessary so you could get a fairly clear look at it.  

    It's behavior right now is to modally gray the entire screen, but the popup window does not show up anywhere.

    If anyone has an idea what I need to change to get it to work, please let me know, I appreciate the help!!

    Regards,

    aspx.vb

    Imports Microsoft.VisualBasic
    Imports System
    Imports System.Web
    Imports System.Web.UI
    Imports System.Text
    Imports System.Web.Configuration
    Imports Telerik.Web.UI
     
    Partial Class Main
        Inherits System.Web.UI.Page
     
        Public aEditButton(11) As RadButton
     
        Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            Dim x As Integer = 0
     
            Do While x < 10
                aEditButton(x) = New RadButton
                aEditButton(x).Text = "Edit"
                aEditButton(x).ID = "EButton" & x
                AddHandler aEditButton(x).Click, AddressOf Me.EditText
     
                RadMultiPage1.PageViews(0).Controls.Add(New LiteralControl("<table><tr><td style=""width: 45px""></td><td>" & x & "</td><td>"))
                RadMultiPage1.PageViews(0).Controls.Add(aEditButton(x))
                RadMultiPage1.PageViews(0).Controls.Add(New LiteralControl("</td></tr></table>"))
     
                x += 1
            Loop
     
        End Sub
     
        Private Sub EditText(ByVal sender As Object, ByVal e As System.EventArgs)
            Dim buttonId As String
            Dim x As Integer
     
            buttonId = DirectCast(sender, RadButton).ID
            x = Mid(buttonId & "  ", 8, 2)
     
            Editor1.Content = x
            editFindings.Items.Add(New RadComboBoxItem(x, x))
     
            Dim script As String = "function f(){$find(""" + modalPopup.ClientID + """).show(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)
     
            Label1.Text += "Got Here..."
        End Sub
     
        Protected Sub bReturn_Click(sender As Object, e As EventArgs) Handles bReturn.Click
            Label1.Text += "Exit Page..."
        End Sub
     
        Protected Sub Timer1_Tick(sender As Object, e As System.EventArgs) Handles Timer1.Tick
            'Processing code here ...
            Label1.Text = "[Auto Stored @ " & Date.Now.ToLocalTime & "]"
        End Sub
     
        Protected Sub editSave_Click(sender As Object, e As EventArgs) Handles editSave.Click
            Label1.Text += "From Editor:[" & Editor1.Content & "]"
        End Sub
     
        Protected Sub editAdd_Click(sender As Object, e As EventArgs) Handles editAdd.Click
            Editor1.Content = Editor1.Content & "<br/>" & editFindings.SelectedValue
        End Sub
    End Class

    aspx

    <%@ Page Title="" Language="VB" AutoEventWireup="false" CodeFile="!Test1.aspx.vb" Inherits="Main" %>
    <html>
      <head runat="server">
        <title> Test </title>
      </head>
    <form id="form1" runat="server">
      <body id="mainBody" runat="server">   
        <telerik:RadScriptManager ID="ScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" Skin="Office2010Blue" EnableRoundedCorners="true" />
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" Runat="server"></telerik:RadStyleSheetManager>
     
        <asp:Label ID="Label1" runat="server"></asp:Label><br />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" >
          <AjaxSettings>                       
            <telerik:AjaxSetting AjaxControlID="Timer1">
            </telerik:AjaxSetting>
          </AjaxSettings>
        </telerik:RadAjaxManager>
     
        <asp:Panel ID="Panel1" runat="server" BorderStyle="Ridge" BorderWidth="3px" Width="95%" HorizontalAlign="Left" DefaultButton="bReturn">
          <table style="width:100%">
            <tr>
              <td  style="text-align: left">
                <telerik:RadButton  ID="bReturn" runat="server" Text="Return" Width="180px" Font-Size="16px"></telerik:RadButton>
              </td>
            </tr>
          </table>
     
          <telerik:RadMultiPage ID="RadMultiPage1" runat="server" Width="100%" SelectedIndex="0">
            <telerik:RadPageView ID="PageView1" runat="server"></telerik:RadPageView>
            <telerik:RadPageView ID="PageView2" runat="server" Width="100%"></telerik:RadPageView>
          </telerik:RadMultiPage>
        </asp:Panel>
     
        <asp:Panel ID="Panel2" runat="server">
          <asp:Timer ID="Timer1" runat="server" Interval="120000" OnTick="Timer1_Tick"/>
          <telerik:RadWindow ID="modalPopup" runat="server" Width="725px" Height="360px" Modal="true" >
            <ContentTemplate>
              <div>
                <table  style="width:725px">
                  <tr>
                    <td>
                      <asp:Label ID="editL1" runat="server" Text="Use this editor to formulate your response to this category"></asp:Label>
                    </td>
                    <td style="text-align:right">
                      <telerik:RadButton ID="editSave" Text="Save" AutoPostBack="false" CausesValidation="false" runat="server" />
                    </td>
                  </tr>
                </table>
                <telerik:RadEditor Width="725px" Height="300px" EditModes="Design" ID="Editor1" runat="server"></telerik:RadEditor><br />
                <asp:Label ID="edit2" runat="server" Text="Choose Item to add to Findings Above"></asp:Label><br />
                <telerik:RadComboBox ID="editFindings" Width="420px" runat="server"></telerik:RadComboBox>
                <telerik:RadButton ID="editAdd" Text="Add" AutoPostBack="false" CausesValidation="false" runat="server" />
              </div>                  
            </ContentTemplate>
          </telerik:RadWindow>
        </asp:Panel>
            
      </body>
    </form>
    </html>


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Jan 2014 Link to this post

    Hi,

    Please try the following code snippet which works fine at my end.

    C#:
    private void EditText(object sender, System.EventArgs e)
    {
        string script = "function f(){showWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        Label1.Text += "Got Here...";
    }

    JavaScript:
    <script type="text/javascript">
        function showWindow() {
            var win = $find("<%=modalPopup.ClientID %>");
            win.Show();
        }
    </script>

    Hope this will helps you.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top