EJ
Posted on 13 minutes ago
i have two situations as I listed earlier:1) needing to display a messagebox modal that shows info and has ok button - radalert seems to be the ticket here if I can get it to work
2) needing to display a usercontrol within a modal window inside of my browser window that is not a popup window - radwindow seems to be the thing to use here - but i need to have two buttons outside of the usercontrol that have "add" or "cancel" - the cancel button can just close the window - the "Add" button needs to call a public method on the usercontrol and if that returns true then it closes the window and passes back a value of what was added (guid or string) otherwise it does nothing and the radwindow continues to be displayed
here's the structure of my page
my code for this is running in a user control that is embedded in a page that has a masterpage
my masterpage has the scriptmanager component
the user control generally is structured like so:
<asp:UpdatePanel ID="MyUpdatePanel" runat="server">
<ContentTemplate>
<asp:FormView ID="MyFormView" runat="server" DefaultMode="Edit" DataSourceID="MyObjectDataSource">
<EditItemTemplate>
<asp:Panel ID="Panel1" runat="server" DefaultButton="ReaderLinkButton">
<asp:LinkButton ID="MyLinkButton" runat="server" OnClick="MyLinkButton_Click">My Link</asp:LinkButton>
</EditItemTemplate>
</asp:FormView>
</ContentTemplate>
</asp:UpdatePanel>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
<Windows>
<telerik:RadWindow ID="MyDialogRadWindow" runat="server" Modal="True">
<ContentTemplate>
<asp:Label ID="MyLabel" runat="server" Text=""></asp:Label>
<uc:MyControl ID="MySpecialControl" runat="server" />
<asp:Button ID="DialogCancelButton" runat="server" Text="Cancel" OnClick="DialogCancelButton_Click"
Visible="false" />
<asp:Button ID="DialogOkButton" runat="server" Text="Ok" OnClick="DialogOkButton_Click" />
</ContentTemplate>
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
</ContentTemplate>
</asp:UpdatePanel>
and my code behind for the linkbutton is
protected void MyLinkButton_Click(object sender, EventArgs e)
{
// this was my attempts at the radalert
// string script = @"
// function f() {
// radalert('" + returnValues[1] + @"');
// }
// Sys.Application.remove_load(f);
// Sys.Application.add_load(f);";
string script = @"radalert('" + returnValues[1] + @"',200,200);";
Page.ClientScript.RegisterStartupScript(typeof(string), "radalert", script, true);
}
i read various posts about this but there does not seem to be a definite method to open/show or close/hide the radwindow that is located inside of a updatepanel inside a user control.
I tried this and it does not work
private void ShowDialog() |
{ |
// define the name and type of the client scripts on the page |
string csname = "showDialog"; |
// get a clientscriptmanager reerence from the page class |
ClientScriptManager cs = Page.ClientScript; |
// check to see if the startup script is already registered |
if (!cs.IsStartupScriptRegistered(csname)) |
{ |
string script = @" |
<script language='javascript'> |
function showDialog(){ |
var oWnd = $find('" + MyDialogRadWindow.ClientID + @"'); |
oWnd.show(); |
Sys.Application.remove_load(showDialog); |
}; |
Sys.Application.add_load(showDialog); |
</script>"; |
cs.RegisterStartupScript(typeof(string), csname, script); |
} |
} |
private void HideDialog() |
{ |
string csname = "hideDialog"; |
// get a clientscriptmanager reerence from the page class |
ClientScriptManager cs = Page.ClientScript; |
// check to see if the startup script is already registered |
if (!cs.IsStartupScriptRegistered(csname)) |
{ |
string script = @" |
<script language='javascript'> |
function hideDialog(){ |
var oWnd = $find('" + MyDialogRadWindow.ClientID + @"'); |
oWnd.Close(); |
Sys.Application.remove_load(hideDialog); |
}; |
Sys.Application.add_load(hideDialog); |
</script>"; |
cs.RegisterStartupScript(typeof(string), csname, script); |
} |
} |
i tried this but it did not help calling it server side
i tried doing the ajax sample here but that did not work either
how do I do this?