Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I keep business logic out of my MOVER form
Message
 
 
À
15/10/2003 06:52:43
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00838481
Message ID:
00838851
Vues:
19
Hi!

>Thanks Vlad
>
>Creating my Mover form as a base page class looks like something I will have to do on my next project.
>At present my abilities are still closely linked to what I can achieve in the web form designer.
>
>I have decided that passing parameters using session is going to be too high overhead for regular use.
>

Why?

>I am looking at using Server Transfer but at first glance this seemed to be a bit awkward.
>My original understanding is that this method would allow me to create and instance of my Moverform. This instance could then reference properties on the form it was called from. I thought this would involve me creating extra properties on all my forms which would be untidy :(
>
>However this link
>
>http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=15
>
>Describes how I can pass values by using Server.Transfer – you can put values into the Context.Items dictionary, which is similar to Session and Application, except that it lasts only for the current request. (search for HttpContext in MSDN). The page receiving postback can process data, store values in the Context, and then Transfer to a page that uses the values.
>
>e.g. Store a message in the context dictionary, and transfer to the default.aspx page (which can then display the message):
>
>Context.Items["Message"] = "Your password was changed successfully";
>Server.Transfer("default.aspx");
>
>
>Do you think it is worth my while investigating Server.Transfer to solve my Mover Form problems?

No.

The best performance is to use approach with passign the query number in URL query string. Then, inside of mover form, look up query by index in some arrays defined globally.

>
>
>
>
>
>
>
>>Hi!
>>
>>>>>It has 2 listboxes on it an I move data from one listbox to another and return the selected output as a record set.
>>>>>
>>>>
>>>>Well, when you move item from one list to another, how it works? Did server code run during that, or it is done by Java Script at the client side?
>>>
>>>I am using server side vb code
>>
>>No problem with that.
>>I meant, after user clicks on the button to move item from one list to another, does page reloads from server?
>>
>>>>>Using web form page classes is a PIA because they can not handle visual components, so I had to rule them out.
>>>
>>>___________________________________________________________________________________________________________________
>>>
>>>>What you meant as "handle visual components"? I made web page class and it is very easy. It handles everything required. .NET WEB page designer opens it very well and even allows place and edit custom (written in C# code only) controls. It was not PIA, it was fun how it was easy and how it did improve things in my code.
>>>
>>>
>>>Well I found a really nice FREE datepicker / calendar control
>>>
>>>http://www.excentricsworld.com/customcontrols.aspx?id=7
>>>
>>>This is proved very useful, but I wanted to subclass it.
>>>I chose ..... Project - Add web user control
>>>and called it CtlCalendar
>>>This gave me a blank form so I dropped my control on it and changed a few properties.
>>
>>This way you did not sub-classed it. You created your NEW control, that is also a container, and that contains an instance of Calendar control. When compare to FoxPro, you created new class based on Container class, and put into it Calendar control.
>>
>>
>>>I re-built my solution and then dragged CtlCalendar.ascx from the Solution Explorer onto my test form
>>>
>>>The new control will not let me posistion it on the form unless I wrap it in a panel. This makes adressing the control a PIA.
>>>
>>
>>???? How it looks like?
>>
>>
>>>I repeated the whole experiment and noticed that the "blank" form generated by
>>>
>>>Project - Add web user control
>>>
>>>actually tells me to wrap my control in to a grid layout panel. Aha says I. But sadly using this panel in the control seems to change nothing.
>>>
>>>I have no idea where am I going wrong in all this...This was such a simple process in Visual Foxpro:(
>>>
>>
>>Well, do you know HTML? Instead of Panel, put a TABLE tag on the page with cells configured properly to position calendar correctly.
>>
>>_____________________________________________________________________________________________________________________
>>>>>I dont mind sending select statements to it via session but I would want to create a code wrapper to launch my Mover form from. My attempt to create a code wrapper failed because the function below will not let me use Response.redirect
>>>>>It complains if System.Web.UI.Page() is not there and it also complains if it is there.
>>>>>The code below is part of a seperate business class.
>>>>>The error is
>>>>>Response is not available in this context
>>>>>
>>>>>
>>>>>Public Class mdata
>>>>>    Inherits System.Web.UI.Page
>>>>>
>>>>> Public Shared Function mover(ByVal myurl As String) As Object
>>>>>            Response.Redirect(myurl)
>>>>>    End Function
>>>>>
>>>>>
>>>>
>>>>Above code does not works because "Shared" declaration. Response is a property of Page object, and you do not have here context of Page object (Inherits would not help here - you need "real" page object which is instantiated by .NET as hit comes to web server). In such case, instead of inheriting of page class, pass page or response object as parameter into function. Something like below (not sure about syntax - writing mostly in C#):
>>>
>>>
>>>>
>>>>Public Class mdata
>>>> Public Shared Function mover(ByVal myurl As String, ByVal CurPage As System.Web.UI.Page) As Object
>>>>            CurPage.Response.Redirect(myurl)
>>>>    End Function
>>>
>>>Then call function from code on real web page as follows: "...mover("someurl", this)"
>>>
>>>>
>>>
>>>
>>>AHA Thankyou....that solves my immediate problem, but now you have got my hopes up that I can use my Mover Form as a class.
>>>
>>>As you will have seen from above my first attempt was a failure. I did searches on the web that seemed to indicate it was not possible to place controls on a web form base without wrapping them in a panel object of somekind.
>>>
>>>It may be possible to do all this using just code. But I want to do it via the web form designer.
>>>
>>>Do you have an example of a page class with controls on it that I can try out.
>>>
>>>I am hoping to do the following.
>>>
>>>1. Create a page with various controls on it.
>>>2. Save this page as a class.
>>>3. Create a new page that inherits from this page and displays the objects from the existing page in the screen builder.
>>>
>>
>>Well, you're trying to do things much like in VFP :-)
>>In .NET, I did not tried to reach such results by way you described. I even do not know if this would work, most likely not. There is no such thing (at least I could not find) as "Save this page as a class". This is because every ASPX page in ASP.NET is already a class.
>>
>>I did not use designer to create page class, I created it using C# source code. You can do the same - it is not hard. Create new WEB form, then take a look to the source code of code-behind file. It just defines new class based on Page class. Including of controls into the class is a bit tricky - it requires to override certain methods of page class and define there base page layout, include controls into it etc., so when you create new instance of page based on your page, all basic HTML with controls in it would be already there.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform