473,320 Members | 1,883 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,320 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 2631
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.