问题描述
目标: - 在服务器端,我需要在一个IF条件自动打开一个radwindow(在aspx页面的JavaScript的定义)
Objective:- From the server-side, I need to open a radwindow(defined in JavaScript of the aspx page) automatically on an IF condition.
code使用: -
在aspx页面,我定义了radwindow为: -
In aspx page, I defined the radwindow as:-
<telerik:RadWindowManager Skin="WBDA" ID="AssetPreviewManager" Modal="true"
EnableEmbeddedSkins="false" runat="server" DestroyOnClose="true" Behavior="Close"
style="z-index:8000">
<Windows>
<telerik:RadWindow ID="DisclaimerAlertWindow" runat="server" Width="720px" Height="220px"
Modal="true" visibleStatusbar="false" VisibleTitlebar="false" keepInScreenBounds="true" title="Sourav">
</telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
在JavaScript中,一个函数用于打开radwindow定义: -
In JavaScript, a function is defined for opening the radwindow:-
function openRadWindow()
{
var oWnd = radopen('DisclaimerAlert.aspx, 'DisclaimerAlertWindow');
oWnd.set_title('Access Denied !');
oWnd.Center();
return false;
}
于是在aspx页面的服务器端,在页面加载事件的IF条件进行检查,然后我打电话'openRadWindow()函数: -
So on the server side of the aspx page, In the Page Load event an IF condition is checked and then I'm calling 'openRadWindow()' function as:-
protected void Page_Load(object sender, EventArgs e)
{
if (fieldValue == "False")
{
string xyz = "<script type='text/javascript' lang='Javascript'>openRadWindow();</script>";
ClientScript.RegisterStartupScript(this.GetType(), "Window", xyz);
}
}
问题: -
但在运行此,这些JavaScript错误就来了 -
But on running this, these JavaScript errors are coming:-
- 对象不支持此属性或方法。
- '未定义'为空或不是对象
请帮忙如何实现我的目标。我完全卡住了。
Please help how to achieve my objective. I am totally stuck.
推荐答案
您好我想与大家分享我的解决方案来创建在Javascript code RadWindow对话框只。
Hi I want to share with you my solution to create RadWindow dialog in Javascript code only.
我们需要实现2种方法:一种用于初始化RadWindow对话,而最后一个用于recieving闭合RadWindow后返回的参数。你可以做你想要在这第二个步骤是什么(e.x回传,...)
We need to implement 2 methods: one for initializing RadWindow dialog, and the last one for recieving the arguments returned after closing the RadWindow. You can do what you want in this second step (e.x postback,...)
下面是我的code:
初始化RadWindow对话框:
Initializing RadWindow dialog:
function openMyDialog(url, args) {
var manageWindow = GetRadWindowManager();
if (manageWindow) {
var radWindow = manageWindow.open(url, "<your_dialog_name>");
if (radWindow) {
radWindow.set_initialBehaviors(Telerik.Web.UI.WindowBehaviors.None);
radWindow.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
radWindow.setActive(true);
radWindow.SetModal(true);
radWindow.center();
radWindow.set_visibleStatusbar(false);
radWindow.set_keepInScreenBounds(true);
radWindow.set_minWidth(640);
radWindow.set_minHeight(480);
radWindow.setSize(640, 480);
radWindow.set_destroyOnClose(true);
radWindow.add_close(closeMyDialog);//after closing the RadWindow, closeMyDialog will be called
radWindow.argument = args;//you can pass the value from parent page to RadWindow dialog as this line
}
}
}
关闭RadWindow对话框:
Closing the RadWindow dialog:
function closeMoveProjectDialog(sender, args) {
var objArgs = args.get_argument();
//objArgs variable stored the values returned from the RadWindow
//you can use it for your purpose
}
如何调用呢?
你可以把open方法到您的预期方法。在我的身边,我有一个方法,如下图所示,我会打电话给RadWindow因为这种方式:
How to call this?You can put the open method into your expected method. In my side, I have a method as shown below and I will call the RadWindow as this way:
function ShowForeignKeyFrontEditSingle(param1, param2){
var url = "ForeignKeyFrontEditSingle.aspx";
var objArgs = new Array();
objArgs[0] = param1;
objArgs[1] = param2;
openMyDialog(url, objArgs);
return;
}
当然,你必须声明一个RadWindowManager控制
Of course, you have to declare a RadWindowManager control
function GetRadWindowManager() {
return $find("<%=your_radwindow_manager_control.ClientID%>");
}
这篇关于动态打开在Javascript中定义的radwindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!