如何使用JavaScript调用其他Webform [英] How to call anther webform by using javascript

查看:72
本文介绍了如何使用JavaScript调用其他Webform的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用C#asp.net通过使用Web应用程序创建了两个Web页(aspx).喜欢

1. Main.aspx
2. Sub.aspx

如何创建
1.业务逻辑层类.
2.如何通过单击按钮从Main.aspx页面调用sub.aspx页面....给出代码和类方法...

如果有任何错误提示我,我是初学者...
感谢您的提前...




问候

Kumar

I have create two Web Pages(aspx) by using web application using C# asp.net. like

1. Main.aspx
2. Sub.aspx

How to create
1. Business logic layer class.
2. How to call sub.aspx page from Main.aspx page using button click.... give the code and class method ...

I am beginner if any mistake in question sugges me...
Thanks for advance...




Regards

Kumar

推荐答案

在主页上添加一个按钮,然后双击按钮并在下面的代码中编写
add one button on main page and double click on button and write below code
response.redirect("sub.aspx");


Kumar,为什么编写代码以在业务逻辑层中打开弹出窗口.
业务逻辑层的目的是不同的.请清楚3层/n层架构的含义.最后,您必须能够理解为什么需要一个层(或层)以及每个层具体做什么.

出现问题时,我假设您需要打开模式/非模式弹出窗口.由于这纯粹是UI事情,因此您无需进入业务逻辑层并从那里打开它.您可以在UI本身中很好地做到这一点.

在Main.aspx.cs中,在按钮click事件中编写如下内容.
Kumar, why do you write code to open a popup window in business logic layer.
Purpose of Business Logic Layer is different. Be clear with what is 3-tier/n-tier architecture is about. At the end of it all, you must be able to appreciate why a tier (or Layer) is required and what each one does specifically.

Coming to you question, I assume that you are required to open modal/nonmodal popup window. Since this is purely a UI thing, you will not be required to go to Business logic layer and open it from there. You can very well do that in UI itself.

In Main.aspx.cs, in the button click event write some thing like below.
void Button_Click(object sender, EventArgs e)
{
   OpenNewWindow("Sub.aspx");
}

public void OpenNewWindow(string url)
{
   ClientScript.RegisterStartupScript(this.GetType(), "SubWindow", String.Format ("<script>window.open('{0}');</script>", url));
}


这应该为您做.否则,尝试使用其他方法在asp.net中打开模式对话框.


This shoould do for you. Else, try out for different ways of opening a modal dialog in asp.net.


要在javascript中实现,请使用以下代码:
在.aspx页中声明您的按钮,
To implement in javascript please use the code below:
Declare your button in your .aspx page,
<asp:Button runat="server" ID="BtnRedirect" Text="Open Popup"  OnClientClick="return OpenWin();"/>


并使用下面的脚本在对话框中打开Sub.apsx.仅在关闭Sub.aspx后,您才能使用父页面.


And use the script below to open the Sub.apsx in dialog. You will be able to work with your parent page only after closing Sub.aspx

<script language="javascript" type="text/javascript">
 function OpenWin() {
    window.showModalDialog('Sub.aspx');
    return false;
 }
</script>


这篇关于如何使用JavaScript调用其他Webform的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆