Please help with user controls

L

Lloyd Sheen

I have now spent 5 hours on google/msdn looking for something useful in the
creation of user controls for asp.net. The VS 2003 has very limited support
for things such as absolute positioning of the control etc.
 
J

Jesse Liberty

I'm not quite sure what you are looking for, but there is extensive coverage
of user controls not only in my book (Programming ASP.NET -O'Reilly) but in
many other books on Programming ASP.NET. As for positioning, you should be
able to position your user control much like any other control; you may want
to take a look at the portal sample (I buy spy) provided by Microsoft, which
makes extensive use of User Controls.

Best of luck.

-j
 
S

Suresh

..NET Quickstart tutorials are always a good starting point
if you haven't looked at them already.

Web Forms User Controls
-----------------------
http://samples.gotdotnet.com/quickstart/aspplus/doc/webpage
lets.aspx

Abosulte positioning can done thru the design mode when
you drag and drop your control on to a web form. Is their
anything more specific you are looking for?

HTH,
Suresh.
 
A

Alex Papadimoulis

Hi Lloyd,

I've found that wrapping all of the user control html in a asp:panel, and
then exposing that style property of the asp:panel as a public property of
the control, it works real well. this way, you can easily position it.
Example:

<%@Control%>
<asp:panel runat=server id=wrapper>
Put the regular control contents overhere ...
</asp:panel>

.... in the codebehind or in a SCRIPT runat=server block,

Public Property Readonly Style as CssStyleCollection
Get
Return wrapper.style
End Get
End Property

-- Alex Papadimoulis
 
L

Lloyd Sheen

I am trying to use VS 2003. The support is so confusing it is useless. The
articles you refer to have no relation to VS that I can see. None of them
use absolute positioning or VS 2003.

I want tutorials using this software. Why would someone spend +$1000 on
software instead of notepad, the answer to make the development cycle
quicker and less error prone. So far in the creation of user controls I see
no support that makes sense. I am assumming that I just do see the correct
path through VS 2003.

Thanks for the link but that was one of the hundreds I have looked at today.

Lloyd
 
L

Lloyd Sheen

Ok guys thank for the help. Let me explain what I have tried.

1. Create a Web User Control within ASP project.
2. Add GridFlow panel and add controls within
3. Drag WUC to the asp page I want to have the control on.

Now the problems commence.

A. No support for absolute positioning of the control.
B. No reference to the control in the VB codebehind page.

So that is useless for my purposes.

Next try.

1. Create Web Control Library

Now the problems commence (already). When I go to add the web control I can
only add windows form controls. Now the help line on the New Project dialog
states "A project for creating controls to use in Web applications". The
problem is that within this project there is no designer support.

Now after some experimenting I see that if I just say add new item then the
selections change. MS please please fix VS. Now there is still no designer
support. What good is an IDE if all you really need is notepad.

All in all totally useless for RAD.

Lloyd Sheen
 
S

Suresh

A. No support for absolute positioning of the control.
You are right. VS.NET ide doesn't seem to support
absolute positioning for a user control. I'm not sure if
there's a setting that'll allow you to control that.
But a possible workaround is to place a control that does
absolute positioning such as a Label and place it in the
form where you want the control. Then take the Style
property text and place it inside your user control.
Hopefully someone here has a more elegant way.
B. No reference to the control in the VB codebehind page.

This is because the object doesn't get declared in the
codebehind automatically. You have to manually add it.
It should be like the following.

Protected <YourUserControlClassName> <IDofyouUserControl>

That should create the reference in your codebehind.

HTH,
Suresh.
 
L

Lloyd Sheen

I have tried some of the things you have suggested.

You are right. VS.NET ide doesn't seem to support
absolute positioning for a user control. I'm not sure if
there's a setting that'll allow you to control that.
But a possible workaround is to place a control that does
absolute positioning such as a Label and place it in the
form where you want the control. Then take the Style
property text and place it inside your user control.
Hopefully someone here has a more elegant way.

I can make the designer place the control by stealing position info from
another control. This is lost when the page renders.
This is because the object doesn't get declared in the
codebehind automatically. You have to manually add it.
It should be like the following.

Protected <YourUserControlClassName> <IDofyouUserControl>

That should create the reference in your codebehind.

My big bitch is that a development IDE that requires the user to do
everything manually is a waste of money. I have tried so many things today
I know that one thing I did created the control. The problem with just
declaring it is that there is no instant of the control during run-time.
 
A

Alex Papadimoulis

Hi Lloyd,

I completely agree with you -- the VS.NET IDE is pretty worthless when it
comes to making decent looking websites. However, it's an essential took
for creating your middle tier classes -- the integration with SQL Server,
intellisense, and so on are all wonderful. I'd advise sticking with
Dreamweaver to develop the ASPX pages and ASCX controls, and just use VS.NET
to develop your middle tier. I've found that to be the most productive
approach.

Alex Papadimoulis
 
L

Lloyd Sheen

Putting the reference does nothing other than creating a variable. It is
never set and cannot be used.
 
L

Lloyd Sheen

Ok, I have a work around, (at least until VS2006). I can create the
variable and in the page load do a FindControl to populate it. To place the
control I can create a panel and use this panel to host the control.

Not exactly what you would expect from a "RAD" product.

Thanks to all for their ideas. An composite of all those ideas was the
parent of the solution.


Lloyd Sheen
 
J

Jeffrey Huntsman

Actually it does. The var must have exactly the same name as that in the
..ASPX/.ASCX html page and should be declared at least as protected or
higher. This works perfectly in C#, but I can't say for VB.

As for your gripes about the product, maybe you should seek some training so
as to reduce the learning curve a little. If you are a MSDN subscriber, be
sure to get the "Whidbey" CD released at October's PDC. The ASP.NET team is
making huge strides in the design-time experience, and I believe in the
user-control arena that you'll probably want to check out.

Jeffrey
 
L

Lloyd Sheen

Jeffrey,
I have been using the MS visual tools since VB1. The biggest problem
with the new VS is that the docs are not up to the task. I have been
compiling of a list of problems with the release and the wait until the next
release is getting a little old.

There are way too many things in the IDE that just don't do the job. I
first set out to learn the .NET framework which has good docs and I was
pleased by the classes which took care of many of the needs that I have been
used to coding myself.

What level of MSDN is required to get the Whidbey "beta". I have
Enterprise and see nothing in any of the categories about it.

Lloyd
 
L

Lloyd Sheen

PS. Thanks for the help. Setting the variable to the correct name fixed
the problem. Now if only that were documented. If it were not for the help
of the people on this newgroup I would have no hair left from all the
scratching.

Lloyd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top