5 Answers, 1 is accepted
Please have a look into the following code snippet to show a RadWindow on OnClick event of RadButton.
ASPX:
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Show RadWindow"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
C#:
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
RadWindow window =
new
RadWindow();
Label lbl =
new
Label();
lbl.Text =
"RadWindow"
;
window.ContentContainer.Controls.Add(lbl);
window.VisibleOnPageLoad =
true
;
form1.Controls.Add(window);
}
Hope this will helps you.
Thanks,
Shinu.
RadWindow1.VisibleOnPageLoad = true; on code behind, problem with this is my webpage will be back again when I click on any UI control it popsup again.
here is the code that I have
every time click on edit from radgrid radwindow pops.
UI:
<
form id="form1" runat="server">
<asp:ScriptManager runat="server"></asp:ScriptManager>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label" Visible="false"></asp:Label>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
AllowPaging="true">
<MasterTableView DataKeyNames="ID" CommandItemDisplay="Top">
<Columns>
<telerik:GridEditCommandColumn>
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="Updatepanel1" runat="server">
<ContentTemplate>
<telerik:RadWindowManager ID="radwinmgr" runat="server">
<Windows>
<telerik:RadWindow ID="RadWindow1" runat="server">
<ContentTemplate>
<center><h1>Submission Report</h1>
The following elections have been made to your account for fixed income elections. Please read
<br />
<table style="width: 700px;">
<tr>
<h2>Election (Level Election)</h2>
<br />
</tr>
<tr>
<asp:CheckBox ID="CheckBox2" runat="server" Text="Premium - Default"></asp:CheckBox><br />
<asp:CheckBox ID="CheckBox3" runat="server" Text="Do not Premium"></asp:CheckBox>
</tr>
</table>
</center>
</ContentTemplate>
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
</ContentTemplate>
</asp:UpdatePanel>
</form>
Code behind:
protected void Button1_Click(object sender, EventArgs e)
{
RadWindow1.VisibleOnPageLoad =
true;
}
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
dynamic data1 = new[] {
new { ID = 1, Name ="Name_1",Customdate = DateTime.Now},
new { ID = 2, Name = "Name_2",Customdate = DateTime.Now},
new { ID = 3, Name = "Name_3",Customdate = DateTime.Now},
new { ID = 4, Name = "Name_4",Customdate = DateTime.Now},
new { ID = 5, Name = "Name_5",Customdate = DateTime.Now}
};
RadGrid1.DataSource = data1;
}
Since you are setting VisibleOnPageLoad property of RadWindow to true, it will open every postback. So one suggestion is that you can call the client side function to show the RadWindow. Please have a look into the following code snippet which works fine at my end.
C#:
protected
void
Button1_Click(
object
sender, 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
);
}
JavaScript:
<script type=
"text/javascript"
>
function
showWindow() {
var
win = $find(
"<%=RadWindow1.ClientID %>"
);
win.Show();
}
</script>
Hope this will helps you.
Thanks,
Shinu.