Thursday, March 22, 2012

Working with User Controls in code Behind

I have the following code in my asp.net page

<%@dotnet.itags.org. Register TagPrefix="DNG" TagName="DotNetGraph" src="http://pics.10026.com/?src=DotNetGraph.ascx" %>
<html>
<DNG:DotNetGraph id=dngchart UserWidth=200 runat=server />
</html>

in my code behind file I have this

dngchart.YAxisValues = iValue

' Set our axis strings
dngchart.YAxisItems = sItems

' Provide a title
dngchart.ChartTitle = "Inventory Breakdown:"

right now my codebehind project doesn't recognize dngChart. When I add it like below it tells me that the methods I am using are not a member of User Control. How can I work with this in code behind?


Protected WithEvents dngchart As UserControl
Your control class name is DotNetGraph, so you have to declare your variable as DotNetGraph not as UserControl.
when I tried that VS gave me an error saying DotNetGraph was not defined
Try issuing this piece of code just prior to referring to your object.


dngChart = Me.FindControl("WebFormUserControl1")

0 comments:

Post a Comment