954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

User Control

Hi y'all


I need to create a user control on a web page and I have no idea whatsoever of how to go about it.
The control should consist of a 3 by 3 grid, with each grid cell having its own color, and also the capability of displaying a value passed to it from an array.
I am using VB.NET 2003.
Thanks


Stanley

standoh
Newbie Poster
3 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

create your user control using the vs.net designer, then create an html table having 3 by 3 cells, give them the colors appropriately. create a public property in the user control for the array list as follows :

your usercontrol code behind :

public class myUserControl 
{
private ArrayList _myArrayList;
public ArrayList myArrayList
{
get
{
return _myArrayList;
}
set
{
_myArrayList = value;
}
}

}

register the usercontrol to the code behind so that you can reach the public properties
myUserControl myUserControlIDonthepage;
when you add the usercontrol to the page, you can fill the array list in the page load event of the page as follows :

void Page_Load(object sender, EventArgs e)
{
myUserControlIDonthepage.myArrayList.Add(myValue);
}

then you can display the items in the arraylist in the html table in usercontrol as follows :

<table>
<tr><td><%=myArrayList[0].ToString()%></td></tr>
</table>

you do that 9 times till you fill all the table with appropriate values

serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127
 

trying it out thanks

standoh
Newbie Poster
3 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

If you need it databound instead of array, you can also put it into a repeater control (the entire table in the itemtemplate block) and bind values to it via page_load. If you need assistance let us know.

SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
 

Thanks

tried out Serkansendur's and it has so far worked, So I am going to try out the second option.

standoh
Newbie Poster
3 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You