CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 3/27/2004 1:58:25 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 21 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
wangweisi
Asp.Net User
Help: Control3/27/2004 1:58:25 AM

0/0

My situation is:
A user control which contains a PlaceHolder(or Panel) object, and this object could be accessed via a public property.

A page contains the user control above and define a PlaceHolder (or Panel) call objP. The objP contains a TextBox, a Button and a RequiredFieldValidator (for validate the textbox).

Now, programmcally add the objP to the user control's PlaceHolder by

usercontrolPlaceHolder.Controls.Add(objP);

but, the validator no longer works. it seems that the event is not been passed,

how should i modified it?
master4eva
Asp.Net User
Re: Help: Control3/27/2004 6:37:59 AM

0/0

I count seven possibilities of why that is happening. Could you post some repro code up.
-- Justin Lovell
wangweisi
Asp.Net User
Re: Help: Control3/27/2004 2:21:03 PM

0/0

--- The User control -------
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebUserControl1.ascx.cs" Inherits="project.WebUserControl1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

//some html here

<asp:PlaceHolder id="cPlaceHolder1" runat="server"></asp:PlaceHolder>


----- code in this user control ----
protected System.Web.UI.WebControls.PlaceHolder plhMainContent;

public ControlCollection ContentControlCollection
{
get { return plhMainContent.Controls; }
}

---- another user control with validator -----
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="LoginControl.ascx.cs" Inherits="project.controls.LoginControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

//some html

<asp:TextBox ID="txtUserName" MaxLength="10" runat="server" />

<asp:RequiredFieldValidator ID="UserNameValidator" ControlToValidate="txtUserName" Display="Dynamic" ErrorMessage="User Name is Blank"
Text="User Name cannot be blank" runat="server" />


----- the page which use both controls above ------
<%@ Register TagPrefix="project" TagName="LoginControl" Src="controls/LoginControl.ascx" %>
<%@ Page language="c#" Codebehind="login.aspx.cs" AutoEventWireup="false" Inherits="project.login" %>
<%@ Register TagPrefix="uc1" TagName="PageTempControl" Src="controls/PageTempControl.ascx" %>

<uc1:PageTempControl id="PageTempControl1" runat="server"></uc1:PageTempControl>

<asp:Panel id="Panel1" runat="server">
<project:LoginControl id="UserLogin" runat="server"></project:LoginControl>
//some other html and controls in this panel
</asp:Panel>

------- the page's code ----
private void Page_Load(object sender, System.EventArgs e)
{
// set up the login action
UserLogin.RegisterLoginFunction(new System.EventHandler(DoLogin));

// addd the panel to the page
this.PageTempControl1.ContentControlCollection.Add(this.Panel1);
}

private void DoLogin(object sender, System.EventArgs e) // method defines how to perform login




Ths reason for I design the page like this is that I want to have a frame control which has a general html frame of the whole site, this frame control should contains a place holder and different contant could be added dynamicly. E.g. for the register page, i just add a RegControl and for the login page, i just add a LoginControl.

Further than above, I have write a class call BasePage, which override the render method so that i could design the <head> of all the pages, this base page class has a HtmlForm object and it is render in the Render method like this:
frmMainForm.RenderControl(writer);
A placeholder is add to the form and public to others

public BasePage()
{
frmMainForm = new HtmlForm();
this.Controls.Add(frmMainForm);
holder = new PlaceHolder();
this.frmMainForm.Controls.Add(holder);
}


public ControlCollection ContentControlCollection
{
get { return holder.Controls; }
}

BUTTTTTTT, what I want is , rather than add the place holder here, I holp to add the PageTempControl here and and page inherits from this BasePage can use the ContentControlCollection method and add the content to it.






master4eva
Asp.Net User
Re: Help: Control3/27/2004 7:09:35 PM

0/0

Ah - this was third on my list. Anyway, this is rather simple when you think about it. Add the following to your base page and everything will work out:

protected override AddParsedSubObject(object o) {
ContentControlCollection.Add((Control)o);
}

-- Justin Lovell
wangweisi
Asp.Net User
Re: Help: Control3/28/2004 12:24:37 AM

0/0

Thank you , but I'm afraid thatquite understand your solution and it still doesn't work
Maybe I made the question too complexed, let's make it simple here

----------------- WebUserControl1.ascx a user control, nothing special in its code page-------------
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebUserControl1.ascx.cs" Inherits="project.WebUserControl1" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

<asp:TextBox id="TextBox1" runat="server" />

<asp:RequiredFieldValidator id="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator" />

<asp:Button id="Button1" runat="server" Text="Button" />



------------ WebForm1.aspx a form page -------------------

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="project.WebForm1" %>
<%@ Register TagPrefix="uc1" TagName="WebUserControl1" Src="WebUserControl1.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">


<asp:Panel id="Panel1" runat="server"></asp:Panel>


<uc1:WebUserControl1 id="WebUserControl11" runat="server"></uc1:WebUserControl1>
</form>
</body>
</HTML>

------------ and it code ------------

private void Page_Load(object sender, System.EventArgs e)
{
//this.Panel1.Controls.Add(this.WebUserControl11);
}



ok, the two
in the page is the makers and indicates whether the control is programmcally added to the panel.
Now the page will display the contents in sequence , ie




<WebUserControl1>
and everything goes well

Then IF I UN-COMMENT the code "this.Panel1.Controls.Add(this.WebUserControl11);" and pragrammcally add the WebUserControl1 to the Panel
the probelm appears,
it no longer perform the client side validation and the data is always posted
....... Thank you for further help
wangweisi
Asp.Net User
Re: Help: Control3/28/2004 2:09:15 PM

0/0

I have compared the code generated
the difference is

<input name="WebUserControl11:TextBox1" type="text" id="WebUserControl11_TextBox1" />
<span id="WebUserControl11_RequiredFieldValidator1" controltovalidate="WebUserControl11_TextBox1" errormessage="RequiredFieldValidator" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;visibility:hidden;">RequiredFieldValidator</span>
<input type="submit" name="WebUserControl11:Button1" value="Button" id="WebUserControl11_Button1" />

-------------
<input name="WebUserControl11:TextBox1" type="text" id="WebUserControl11_TextBox1" />
<span id="WebUserControl11_RequiredFieldValidator1" controltovalidate="WebUserControl11_TextBox1" errormessage="RequiredFieldValidator" isvalid="False" evaluationfunction="RequiredFieldValidatorEvaluateIsValid" initialvalue="" style="color:Red;">RequiredFieldValidator</span>
<input type="submit" name="WebUserControl11:Button1" value="Button" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="WebUserControl11_Button1" />





6 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Boundaries with Kids: When to Say Yes, when to Say No to Help Your Children Gain Control of Their Lives Authors: Henry Cloud, John Sims Townsend, Lisa Guest, Pages: 223, Published: 1998
What to Eat If You Have Diabetes: Healing Foods That Help Control Your Blood Sugar Authors: Maureen Keane, Daniella Chace, Pages: 288, Published: 2006
A Parent's Guide to Asthma: How You Can Help Your Child Control Asthma at Home, School, and Play Authors: Nancy Sander, Pages: 263, Published: 1994
Games to Grow on: Activities to Help Children Learn Self Control Authors: Lawrence E. Shapiro, Pages: 138, Published: 1981
User's Guide to Natural Treatments for Lyme Disease: Learn how Nutritional and Other Therapies Can Help You Control Your Symptoms Authors: James Gormley, Caren F. Tishfield, Jack Challem, Pages: 86, Published: 2006
In Bad Taste: The MSG Syndrome : how Living Without MSG Can Reduce Headache, Depression and Asthma, and Help You Get Control of Your Life Authors: George R. Schwartz, Pages: 123, Published: 1988
Multiple Sclerosis: Over 100 Recipes to Help Control Symptoms Authors: Geraldine Fitzgerald, Fenella Briscoe, Pages: 169, Published: 1996
Diets to Help Control Cholesterol Authors: Roger Newman Turner, Pages: 0, Published: 1993
Yeast-free Feast: Recipes and Ideas to Help Control Yeast Related and Other Environmental Health Problems Authors: Paula Medd, Pages: 120, Published: 1988

Web:
Microsoft Security Bulletin MS07-008: Vulnerability in HTML Help ... Vulnerability in HTML Help ActiveX Control Could Allow Remote Code Execution ( 928843) .... Features that are provided by the HTML Help control in Enterprise ...
Asthma you can help your child gain control over asthma. That ..... plays with the toy. Wash stuffed toys and dry them. completely to help control dust mites. ...
Control-Escape Control-Escape will help you take control of your computer and escape the restrictions of monopoly commercial software. If you are interested in saving ...
Deseret News | Can drinking coffee help control type 2 diabetes? Can drinking coffee help control type 2 diabetes? By James Thalman Deseret News. Published: Monday, Oct. 13, 2008 12:06 a.m. MDT ...
Continuous monitoring devices help adults control diabetes ... New research shows that adults with type 1 diabetes who use continuous glucose monitoring devices to help manage their disease control their blood sugar ...
Probiotic may help control Crohn's disease Probiotic may help control Crohn's disease. Monday, Oct. 20, 2008; 5:26 PM. NEW YORK (Reuters Health) - French scientists have found that a microbe normally ...
Fall tillage can help control soybean disease Oct 28, 2008 ... Fall tillage operations become a consideration at harvest time, and plentiful soil moisture makes moisture conservation a non-issue.
Vegetarian diet: Can it help me control my diabetes? - MayoClinic.com Although switching to a vegetarian diet won't cure diabetes, it may offer some benefits.
Cells In Eye Could Help Control Sleep Aug 26, 2008 ... A set of nerve cells in the eye control our levels of sleepiness according to the brightness of our surroundings, Oxford University ...
New UNC laboratory to help track and control tropical diseases Sep 25, 2008 ... The University of North Carolina at Chapel Hill School of Public Health has established a new Gillings Innovation Lab to track and map ...

Videos:
Help Control Your Blood Glucose: Attention diabetic patients on medicare! Help Control Your Blood Glucose: Call 1-800-840-7711 or visit http://www.DiabetesCareClub.com to have one of...
THE 100 DAY CHALLENGE- DAY 17- HELP!- CONTROL DRAMAS awful.
How Our Government Can Help To Keep The Cost of Homeowner's Insurance Under Control Some REAL reasons why the cost of homeowner's insurance is rising.
New Drug to Treat Type 1 and Type 2 Diabetes (May 2005) FDA recently approved a new injectable drug to help control blood sugar in adult patients with Type 1 and Type 2 diabetes. It's called Symlin, or pra...
Serious Skin Care Oil Control Trio - Item: 848-719 Tired of your face looking and feeling like an oil slick halfway through your day? Serious Skin Care's Oil Control Trio is from the Oily/Combinatio...
Nvision: Virtual Characters to Help Control Freak Battlestar Galactica Actress Tricia Helfer http://www.uberpulse.com/us/2008/08/nvision_technology_to_help_control_freak_battlestar_galactica_actress_tricia_helfer.php
Parkinson's Disease Parkinson’s Disease is a progressive degenerative disease that destroys a part of the brain, in particular the midbrain’s basal ganglia, and it helps...
Time Control V5 beta Help Inof on Time Control V5 beta.
Control of PM 10 Fugitive Dust From Unpaved Roadways, Yards, Laydown Areas and Other Open Dust Sources The leading source of fugitive dust comes from industrial sources such has unpaved roadways, yards and laydown areas. Learn how dust control can help...
Predator Control in Alaska A California congressman says Alaska is violating federal law by hunting wolves from airborne vehicles. Alaska says they're not hunting, but trying t...




Search This Site:










checkbox help

data entry module

asp in c#.net

open source .net forum

a dropdownlist with the datagrid control

storing objects in session

trying to talk to my usercontrol

referencing session variables from a code module???

doctype html public - problem

calendar object question

about listbox

bit fields in ms sql

hyperlink text file download

ngen and webservices

403 forbidden error when trying to access a webservice

failed to convert parameter value from a string to a decimal.

referencing a label object with instance name as string (what?)

server variable

browse file dialog in aps .net 2.0 w/c#

server error

itemdaatbound evetn

static controls vs dynamic controls..!!

asp.net web form - close event

stopping the 100-continue header being sent

comparevalidator and date types (null?)

iis

mysql database and retrieving fields

word.applicationclass version issue?

vss version number in vb files?

radiobutton lists

  Privacy | Contact Us
All Times Are GMT