473,226 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

WebUserControl

Hi There,

I have a webusercontrol and it works allright when created at design time.
But when I try to create it at the runtime (this is because the number of
control needed is variable) I could not make them visible.

I put a line at the definitions like this,

protected userctrl[] controls;

and in Page_Load method

int count = 3;

controls = new userctrl[count];
for (int i=0; i<count; i++)
{
controls[i] = new userctrl();
controls[i].Visible = true;
TableRow tr = new TableRow();
TableCell td = new TableCell();
td.Controls.Add(controls[i]);
td.Controls.Add(lbl);
tr.Cells.Add(td);
Table1.Rows.Add(tr);
}

And one more thing that made me confused. In some article I read on the Net
tells that when I drag&drop the ascx file on to the web form it puts the
control on the form (which is correct) and it adds this line to the code
protected userctrl userctrl1;
which is not happening for me, it just adds a line to the html code of the
page, nothing on the code behind...
I tried both selecting and deselecting "Run As Server Control" checkbox of
the user control...
What am I missing?
Thanks in advance
Serdar KALAYCI
Nov 18 '05 #1
1 2612
Got that!
instead of writing
controls[i] = new userctrl();

write this
Control controls[i] = LoadControl("userctrl.ascx");
"Serdar Kalaycý" <se***********@unisec.com.tr> wrote in message
news:ue*************@TK2MSFTNGP12.phx.gbl...
Hi There,

I have a webusercontrol and it works allright when created at design time.
But when I try to create it at the runtime (this is because the number of
control needed is variable) I could not make them visible.

I put a line at the definitions like this,

protected userctrl[] controls;

and in Page_Load method

int count = 3;

controls = new userctrl[count];
for (int i=0; i<count; i++)
{
controls[i] = new userctrl();
controls[i].Visible = true;
TableRow tr = new TableRow();
TableCell td = new TableCell();
td.Controls.Add(controls[i]);
td.Controls.Add(lbl);
tr.Cells.Add(td);
Table1.Rows.Add(tr);
}

And one more thing that made me confused. In some article I read on the Net tells that when I drag&drop the ascx file on to the web form it puts the
control on the form (which is correct) and it adds this line to the code
protected userctrl userctrl1;
which is not happening for me, it just adds a line to the html code of the
page, nothing on the code behind...
I tried both selecting and deselecting "Run As Server Control" checkbox of
the user control...
What am I missing?
Thanks in advance
Serdar KALAYCI

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Christian | last post by:
Hi, I try to change the position of a WebUserControl on my WEbform (layout is set to GridLayout) by changing the absolute position in the html-code but it does not work. When I change the...
0
by: Mike Levin | last post by:
Hello Group, I'm using VisualStudio.NET and put a DataGrid into a WebUserControl (an ascx file). For the DataGrid element, I have set AllowSorting="True" and OnSortCommand="Grid_Sort".
2
by: Arun | last post by:
I am new to ASP.NET I need some help for this scenario The scenario is like this I have a template Page which loads a WebUserControl (uct1.ascx) inside a PlaceHolder (PH1) Now this Web User...
1
by: DichkoSoft | last post by:
Hi I create WebUserControl and very confused when use control For Example: ***************************** *wuc.ascx ***************************** <script id=clientEventHandlersJS...
0
by: Christian H | last post by:
Hello, I've just created a WebUserControl that consists of a few other controls such as DropDownList, TextBox and Button. Based on the information entered in the DropDownlist, and TextBox, the...
2
by: Oren | last post by:
Hello everyone... I have a simple WebUserControl with Button and TextBox on it. Webform1.aspx contains this WebUserControl. How can I create my own C'tor for this WebUserControl - I mean when I...
2
by: Oren | last post by:
Hi everyone, I have WebUserControl on a Webform. How can I sent dynamically to the WebUserControl from a Function/Property on the Webform ? <uc:myuc id="myid1" CurrentPage=<%#GetText()%>...
0
by: Giovanni | last post by:
Dear Friends, I have a decision to make and hope to get some insight: I have built several WebUserControls one of which is a WebUserControl that queries an SQL server database, retrieves a...
0
by: Klaus Jensen | last post by:
Hi In a repeater-control, in the <SeparatorTemplatei have placed a webusercontrol, I have made. That works great- However, I want to know be able to only display this WebUserControl a certain...
1
by: deeparengan | last post by:
hi in asp.net i have a webusercontrol that has three dropdownlist.In the first dropdownlist i loaded the data at design time and in second dropdownlist i load the some data at run time according to...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.