Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Updated 26-Jul-12 1:40am
v2
Comments
efkah 25-Jul-12 8:48am    
Considering your response on solution 1 your question should be "how to reference to code in Global Assembly Cache"

add one button on main page and double click on button and write below code
HTML
response.redirect("sub.aspx");
 
Share this answer
 
v2
Comments
shankumar_cst 25-Jul-12 6:44am    
Yeah ur answer is ok but.... I want create one class and the button click call that class and call the sub.aspx through class..... this is i want
bbirajdar 25-Jul-12 9:08am    
You need to revise your concepts in asp.net. Calling the UI from business layer is wrong approach...
shijuse 25-Jul-12 7:06am    
Create class and implement the method to call sub.aspx in that class.On the button click create the object of the class and call that method.
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.
C#
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));
}

This shoould do for you. Else, try out for different ways of opening a modal dialog in asp.net.
 
Share this answer
 
v2
Comments
shankumar_cst 26-Jul-12 7:22am    
thank u dasarathi.. this code is working.....
Now i have one more requirement from u....


My requirement is

1. when Sub.aspx (popup window) opens, the user should not allow to access the Main.aspx.. But parent page could view behind the popup window..

2. after we close the Sub.aspx(popup window), then only user can access the parent page(i.e.Main.aspx)

My friend's r said, we can implement through JavaScript. Can any one plz guide me through sample code. It's very helpful for my project.

I have used (window.open ) for popupwindow.. In my project I should not use modular dialogbox for popup window...

Thanks In Advance
To implement in javascript please use the code below:
Declare your button in your .aspx page,
XML
<asp:Button runat="server" ID="BtnRedirect" Text="Open Popup"  OnClientClick="return OpenWin();"/>

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
XML
<script language="javascript" type="text/javascript">
 function OpenWin() {
    window.showModalDialog('Sub.aspx');
    return false;
 }
</script>
 
Share this answer
 
Comments
shankumar_cst 26-Jul-12 9:25am    
hi i am using your code but i got this error how can i rectify and one more thing ....tell me where i can put codes?


Server Error in '/' Application.
--------------------------------------------------------------------

Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
Dasaradhi_r 26-Jul-12 9:53am    
Hi,
Are you referring AjaxControlToolkit.dll in your app?
If not, You might have added this to "add assembly" section of web.config.
Comment that line of code and see if error is gone.
If error is gone and you want the assembly to be referred, you have two options. 1) Uncomment the above line in web.config and Add the dll to GAC
or 2) Keep it commented and refer the dll from a physical location.

Regarding where to put the code:
Button should be kept inside your <form> tag of your aspx page and
The script must be put inside the <head> tag of your page.
shankumar_cst 26-Jul-12 10:56am    
Will u suggest without ajax..... its not work yeah....
shankumar_cst 27-Jul-12 4:33am    
what is the tool in ajax.... and where can i put the ajax tool.... explain me...
Dasaradhi_r 27-Jul-12 4:47am    
Hi Kumar, be clear with the below thing:
Are you referring AjaxControlToolkit.dll in your app? or
In your web.config just find AjaxControlToolkit.dll is written any where?
Let me know, I can suggest you what to do from there.
Add one button on main page and double click on button and write below code
in that button click call your method in business class and then use
HTML
HttpContext.Current.Response.Redirect("sub.aspx");
then it will redirects to that page
 
Share this answer
 
v2
Comments
shankumar_cst 25-Jul-12 9:14am    
thank eleya its work .... but i dont want redirect .... i want the sub page open new window like popup window....?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900