Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I keep business logic out of my MOVER form
Message
From
16/10/2003 06:32:02
 
 
To
15/10/2003 09:52:58
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00838481
Message ID:
00839159
Views:
29
>>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?
>
>Well I thought I had read somewhere that using session involved 2 trips to the server. But as you will have noticed I am very green in >Net :)
>

No, that is not true. Session is a pure server-side object that does not cause any redirects ore client-server interactions.

>
>>
>>>I am looking at using Server Transfer but at first glance this seemed to be a bit awkward.
>>>Do you think it is worth my while investigating Server.Transfer to solve my Mover Form problems?
>>
>>No.
>
>I will abandon this research then.
>
>>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.
>
>Most of my SQL string require a Parameter passing into them. Since I assume the array is populated with these SQL string when it starts, what is your favoured way of getting the right paramters into these SQL strings.
>
>Do you have some sample code that you use I could have.
>
>Thanks in advance

Well, in ASP (not .NET app) I used string prefix for application variable. For example, Application("usr_OneRecordQuery") = "SELECT * from users where userID={}"
You can have a lot of other params for "usr" form and table, for example, list of fields, what fields are displayed in lists, what are searchable etc. I pass form prefix "usr" into generic forms and they just take queries from application variables:
Application(prefix+"_OneRecordQuery).

Later, I hanged this approach to read all these data from database (and put in application variables), so it is not all hard-coded. It is called application meta-data resources.

In your case, in .NET it could be made even better. I do not have a code sample to send here. Just create a class in source code that will return you object by index or by prefix. Object will contain all properties required for form working, like SQL query, field name to display in list, field name to use as value in list etc. In generic form, receive prefix in URL query string parameter and call public function of that class, for example, "GetInfoByPrefix" or something like that. Function will return object with required infor in it's properties.

But this is just how to organize it better inside of a single app.

When talk about code reusability (re-use your mover in other applications), I still recommend to create custom control.

>
>
>
>>>>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform