views:

168

answers:

1

Hi,

I'm creating a comments web user control. I want to use this comments control on distinct pages like: articles, attractions and categories.

So, on the articles page I delcare the Web User Control

 <uc1:Comments ID="Comments1" runat="server"  />

On the control, there is a funtion call loadComments

public void LoadComents(int ID,string type)
{
        //Load the comments into an asp.net repeater that resides on the control 
}

which I want to call once I have validated that the article exists. So on the article page I want do something like

Comments1.LoadComents(101,"article");

Is this possible?

A: 

You can use code like this from inside of your Page class:

Comments commentsControl = this.FindControl("Comments1");
commentsControl.LoadComents(1, "someType");

Or if the control exists on the page in Designer, you should be able to do something as simple as:

this.Comments1.LoadComents(1, "someType");
Justin Niessner
Thanks Justin,I was doing that and some how it dosn't work, but know it's working
roncansan