Ask a Question related to ASP.NET General, Design and Development.
-
Lewis Wang [MSFT] #1
RE: ASP.NET Model-View-Controller design question
Hi Stan,
Natty is right. The controller should be kept in session to preserve data.
I found that you need page B pops up when Add button is clicked. So, if
you want to pop up B in a new window and then the controller interact
between two windows, you can try this way:
In page A:
1.pop pop up using javascript in A:
<asp:HyperLink id="HyperLink1" style="Z-INDEX: 102; LEFT: 80px; POSITION:
absolute; TOP: 184px" runat="server"
NavigateUrl="javascript:Add_window=window.open('Pa geB.aspx?parameter=aaa','A
dd_window','width=154,height=188');Add_window.focu s()">Add</asp:HyperLink>
2.Initial Controller in A:
Session["controller"]=new Controller();
...
In page B:
1.Add a Literal web forms control to B first, ID=Literal1
2.If you click SaveButton in B, you should save data, refresh parentwindow,
and then close B:
private void Button1_Click(object sender, System.EventArgs e)
{
//Update database using controller,
like:((Controller)Session["controller"]).save();
//Refresh parent window:
string strjscript = "<script language='javascript'>";
strjscript+="window.opener.location.reload();";
//close B
strjscript +="window.close();";
strjscript += "</script>";
Literal1.Text= strjscript;
}
In page A:
The page_load in A gets new data from database and displays one more row.
For more information, please check the following article:
HOW TO: Access ASP.NET Intrinsic Objects from .NET Components by Using
Visual C# .NET
[url]http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B810928[/url]
Microsoft Patterns Web Presentation Patterns
[url]http://msdn.microsoft.com/architecture/patterns/03/default.aspx[/url]
HTH
Please let me know if you want more information, thanks.
Best Regards,
Lewis
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Stan" <nospam@yahoo.com>
| Subject: ASP.NET Model-View-Controller design question
| Date: Fri, 18 Jul 2003 17:33:23 -0400
| Lines: 32
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <Or2MMQXTDHA.3188@tk2msftngp13.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 12.148.36.131
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftn gp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:160427
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| I want to make two pages interact through a controller.
|
| 1. Page A has a grid and Add button.
| 2. When Add button is clicked Page B pops up.
| 3. User enters information and clicks Save
| 4. Information is saved in database
| 5. User goes back to Page A which gets new data from database and displays
| one more row.
|
| So, the event handler for Add button on Page A might look like:
|
| private void btnAdd_Click(object sender, System.EventArgs e)
| {
| Server.Transfer (string.Format ("PageB.aspx?id={0}", id));
| }
|
| but I want PageA to instantiate a controller class, which would in turn
| transfer to Page B, Page B would collected data from a user and again
would
| called the controller to save data and controller would transfer back to
the
| Page A.
|
| My problem is that I don't know where to put the controller code.
|
| I would like the controller to be an independent class. However, if I do
| that, how does the controller get reference to the current http context
and
| object (to do Server.Transfer for example)?
|
| Thanks,
|
| -Stan
|
|
|
Lewis Wang [MSFT] Guest
-
DW Split View - Design View
When working in DW in Split View, when the user clicks into the Design View window the view automatically updates the view if code view has changed.... -
cross section view of 3D model in director
Hello everyone I would like to know if it is possible to create cross section views (to define a cutting plane to be able to look inside the... -
Camera zooming, general 3D model view interaction
hello i'm working on a viewer for 3D models. the possibilities of interaction are: - zooming by moving RMB - orbiting by moving LMB -... -
question: culling model to view frustum
Greeting: Is there a way to detect if the model is inside the camera's view frustum or not? Thanks for the help! hch -
Wierd error when going to Design View from HTML view
When I go from HTML view (in a webform) to Design View I get the following error: Could not open in Design view. Quote values differently inside a... -
Stan #2
Re: ASP.NET Model-View-Controller design question
HttpContext.Current is what I need!
Thanks,
-Stan
"Natty Gur" <natty@dao2com.com> wrote in message
news:OAuKxloTDHA.1556@TK2MSFTNGP10.phx.gbl...> Hi,
>
> You should keep the controller in the session tp preserve its state. you
> can use HttpContext.Current to get the current context from your
> controller.
>
>
>
> Natty Gur, CTO
> Dao2Com Ltd.
> 28th Baruch Hirsch st. Bnei-Brak
> Israel , 51114
>
> Phone Numbers:
> Office: +972-(0)3-5786668
> Fax: +972-(0)3-5703475
> Mobile: +972-(0)58-888377
>
> Know the overall picture
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Stan Guest



Reply With Quote

