473,765 Members | 2,203 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2691
Got that!
instead of writing
controls[i] = new userctrl();

write this
Control controls[i] = LoadControl("us erctrl.ascx");
"Serdar Kalaycý" <se***********@ unisec.com.tr> wrote in message
news:ue******** *****@TK2MSFTNG P12.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
1630
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 position at design-time for my user control by changing it directly in html-code is the change reflected in the design view (and vice-versa). But when I run the app is the control always positioned at the same location (somewhere topleft on the page)
0
1001
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
2109
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 Control (uct1.ascx) has a table with 2 rows First row has a 5 text boxes 2 Combobox and 6 buttons (all Server Controls)
1
1973
by: DichkoSoft | last post by:
Hi I create WebUserControl and very confused when use control For Example: ***************************** *wuc.ascx ***************************** <script id=clientEventHandlersJS language=javascript>
0
1119
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 Button.onClick event quries a database, and returns a DataTable. Because I'm going to use this control different places, and bind the DataTable in different ways (sometimes a datagrid, sometimes repeater) , I added a delegate...
2
275
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 run Webform1.aspx I want to send data to the UserControl (fill Textbox1.Text). any samples ? thanx,
2
315
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()%> data="2" runat="server"/> ..... GetText()-> function/property on the Webform, returns string and send it to the WebUserControl -> <%#GetText()%>
0
1180
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 filename and loads an image control. The WebUserControl itself contains an SQLDataSource and an image box. I also have other WebUserControls that implement the same concept as previously mentioned. The SQLDataSource is bound to a session variable...
0
1102
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 number of times. Basicly I need the WebUserControl itself to know, how many other instances of the webusercontrol was displayed on the page, when I run it.
1
1185
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 the selected value in first drop downlist and in the third i loaded the values none,and,or. I want coding to display same webusercontrol while i click the values and,or in third dropdownlist placed in webusercontrol.
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9951
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.