Calling a Asp.net UI ExpertsCalling a Asp.net UI Experts
Old forum URL: forums.lhotka.net/forums/t/1289.aspx
RangerGuy posted on Wednesday, September 20, 2006
My Clsa bjects are about 90% done now :)
So for a change of pace I wanted validate some of my ideas on how we can handle our UI requirements. We are going to have some Composite Controls (Asp.net 2.0 flavour)
I have my first one working good and validating the input from the user nicely.
My problem is formatting. The control has a Label,Radiobuttonlist and 2 validators (required field and regex validator).
I want the "*" to show up on the right side of the fields when an error is raised. Is it possible to do this. I"ve tried creating table / row / cell
objects and adding the controls to the appropriate cells of row but the only controls that end up in there are the validators :(
Also.. I'm trying to figure out how to change the background color of the rows that are generated to hold the individual radio buttons of
the radiobuttonlist object.
I have been searching online most of today.. looking for a good tutorial and experimenting with not much luck.
What is the best way to apply a layout to a composite control. My controls will inherit from System.Web.UI.WebControls.CompositeControl
I know this isn't really Csla related but any help would be really really appreciated :)figuerres replied on Wednesday, September 20, 2006
RangerGuy: My Clsa bjects are about 90% done now :)
So for a change of pace I wanted validate some of my ideas on how we can handle our UI requirements. We are going to have some Composite Controls (Asp.net 2.0 flavour)
I have my first one working good and validating the input from the user nicely.
My problem is formatting. The control has a Label,Radiobuttonlist and 2 validators (required field and regex validator). I want the "*" to show up on the right side of the fields when an error is raised. Is it possible to do this. I"ve tried creating table / row / cell
objects and adding the controls to the appropriate cells of row but the only controls that end up in there are the validators :(
Also.. I'm trying to figure out how to change the background color of the rows that are generated to hold the individual radio buttons of
the radiobuttonlist object. I have been searching online most of today.. looking for a good tutorial and experimenting with not much luck.
What is the best way to apply a layout to a composite control. My controls will inherit from System.Web.UI.WebControls.CompositeControl
I know this isn't really Csla related but any help would be really really appreciated :)
first I think I know what you are trying to get working with the validators....
when I setup a web form I have a validation summary, the "items" the validators and the submit button etc...
I use a table with 3 columns label , input (textbox etc...), error/validator
you need to set the right properties for it to do the "right thing" dynamic display, message and text each have to be setup right.
.Display = Dynamic
.Text = "*"
.ErrorMessage = "Some Error"
should cause no display untill validation fails, an "*" on the line that fails, the message in the validation summary control.
see if that works right for you...
RangerGuy replied on Thursday, September 21, 2006
Thanks :) figuerres
Sorry for the delayed post.. I've been working like mad today building these controls.
So I got 3 done.. thanks to your help :)
I have noticed that I need to loop thru all the controls in the page for the validation summary to display all the errors.
I created this function to find the a specific control from the form.
protected Control IterateThroughChildren(Control parent,string controlID)
{
Control foundControl = null;
foreach (Control c in parent.Controls)
{
if (c.ID == controlID)
{
return c;
}
if (c.Controls.Count > 0)
{
foundControl = IterateThroughChildren(c, controlID);
if (foundControl != null)
{
return foundControl;
}
}
}
return null;
}
If I don't put the following code in the page_load method. My validation summary control does not display the error messages. Any Ideas why it would need me to loop through all the controls manually?
if (Page.IsPostBack)
{
foreach (CustomerInfo cInfo in _customerlist)
{
_radiobuttonlist = (RadioButtonList)IterateThroughChildren(PlaceHolder1, "Cust" + cInfo .CustID);
if (_radiobuttonlist != null)
{
if (_radiobuttonlist.SelectedItem != null)
{
Response.Write("" + _radiobuttonlist.SelectedItem.ToString());
}
}
}
}
RangerGuy replied on Thursday, September 21, 2006
I figured it out.. not sure why but it seems that I need to call EnsureChildControls() in OnInit method of my composite control. I was under the impressoin from the articals i have been reading that you shouldn't have to call this method anymore if you inherit from the CompositeControl object.
I'm going to do some more reading and see if I can find out why :)Copyright (c) Marimer LLC