大家好我设计了一个radwindow管理器,它有一个下拉列表,一个文本框和一个按钮放在更新面板中。
每件事都运行正常但按下按钮我关闭我的窗口管理器如下
RadWindowManager1.Windows[0].VisibleOnPageLoad = false;
但这不起作用可以帮助我这是我的设计和代码
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Behavior="Default"
InitialBehavior="None">
<Windows>
<telerik:RadWindow ID="RadWindow1" runat="server" Behaviors="Default" InitialBehaviors="None"
OpenerElementID="btn" Width="650" Height="480" VisibleOnPageLoad="false">
<ContentTemplate>
<asp:UpdatePanel ID="up" runat="server" OnUnload="up_Unload">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rdcmb" EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="radbtn" EventName="Click" />
</Triggers>
<ContentTemplate>
<telerik:RadComboBox ID="rdcmb" runat="server" AutoPostBack="true" OnSelectedIndexChanged="sel">
<Items>
<telerik:RadComboBoxItem Text="One" Value="One" />
<telerik:RadComboBoxItem Text="Two" Value="Two" />
<telerik:RadComboBoxItem Text="Three" Value="Three" />
<telerik:RadComboBoxItem Text="Four" Value="Four" />
</Items>
</telerik:RadComboBox>
<telerik:RadTextBox ID="rdText" runat="server">
</telerik:RadTextBox>
<telerik:RadButton ID="radbtn" runat="server" Text="Save" OnClick="btn_Click">
</telerik:RadButton>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
<telerik:RadButton ID="rdbtnwhAnother" Text="Add WithHolding" runat="server" ButtonType="LinkButton"
OnClick="rdbtnwhAnother_Click">
</telerik:RadButton>
代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
RadWindowManager1.Windows[0].VisibleOnPageLoad = false;
}
}
protected void rdbtnwhAnother_Click(object sender, EventArgs e)
{
RadWindowManager1.Windows[0].VisibleOnPageLoad = true;
}
protected void btn_Click(object sender, EventArgs e)
{
RadWindowManager1.Windows[0].VisibleOnPageLoad = false;
}
protected void sel(object sender, EventArgs e)
{
rdText.Text = rdcmb.SelectedItem.Text;
}
protected void up_Unload(object sender, EventArgs e)
{
/* Cast sender as an updatePanel, and use reflection to invoke * * the page's scriptmanger registerUpdatePanel() method * * */
//RadWindowManager1.Windows[0].VisibleOnPageLoad = false;
UpdatePanel aUpdatePanel = sender as UpdatePanel;
MethodInfo m = (
from methods in typeof(ScriptManager).GetMethods(
BindingFlags.NonPublic | BindingFlags.Instance
)
where methods.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")
select methods).First<MethodInfo>();
m.Invoke(ScriptManager.GetCurrent(aUpdatePanel.Page), new object[] { aUpdatePanel });
}
答案 0 :(得分:4)
<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 clientClose(arg) {
getRadWindow().close(arg);
}
</script>
<telerik:RadButton ID="radbtn" runat="server" Text="Save" OnClick="btn_Click">
</telerik:RadButton>
protected void btn_Click(object sender, EventArgs e)
{
string script = "clientClose('');";
ScriptManager.RegisterStartupScript(Page, typeof(Page),
"closeScript", script, true);
}