Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I keep business logic out of my MOVER form
Message
De
14/10/2003 11:28:32
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00838481
Message ID:
00838562
Vues:
17
Hello Vlad

Its great to hear from you again, so you are doing .net as well. That is good news for me!

>>
>>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


>>At present I store several select statements in the Mover form code.
>>I send a parameter indicating what select statements I want to be run.
>>
>>This is bad since my mover form has now has application code in it and I want it to be something I can use with all my web form apps.
>>
>
>Well, this is not an excellent good solution, but you can pass them using Session variables. Not excellent, because it might fail in case the same user opens second browser window and tries to open mover list in both windows at the near-to-the-same time. Rare situation though, so session variables is better than other ways.

>>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.
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.

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:(
_____________________________________________________________________________________________________________________

>
>
>>I dont want to send a select statement in the URL to the Mover form.
>>
>
>You can store all select statements in some globally-defined array or so. Then access them by index. Pass in the URL index into that array.

Thats a good idea.

>
>>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.




>>
>>So far am am having a lot of problem creating re-usable code involving .Net web forms.
>>Can someone please outline a good strategy for me to use
>
>Well, the best approach for creating re-usable code is create new (custom) controls. I would recommend to learn this better - it would save you a lot of time in the future.
>
>>Many Thanks.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform