Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

user control public properties unaccessible from codebehind

Posted on 2008-10-15
6
Medium Priority
?
846 Views
Last Modified: 2013-11-07
I have a user control that I cannot access the public properties. I have given it a classname directive and it still does not show up in my codebehind.

I have scoured this site and all over looking for solutions. Everything I read shows me this is a nobrainer, so there is obviously something I'm missing.

Any ideas?

Attached is the user control snippet
<%@ Control Language="C#" ClassName="WxViewer" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="Weather" %>
 
<script language="c#" runat="server">
 
    private Decimal _latitude = new Decimal(35.47);
    private Decimal _longtitude = new Decimal(-97.45);
    private string _areaname = "Enid";
    
    private string _cssClassWarm = "Warm";
    private string _cssClassCold = "Cold";
    private string _cssClassNormal = "Normal";
 
    private Unit _width = Unit.Parse("50%");
 
    
    public string longtitude
    { set { _longtitude = Decimal.Parse(value); } }
 
    public string latitude
    { set { _latitude = Decimal.Parse(value); } }
 
    public string areaName
    { set { _areaname = value; }
        get { return _areaname; }    
    }
    
   <<<<< snip >>>>>>>
    
</script>
 
<h1><asp:label runat="server" ID="lblAreaName"/> Area Weather Outlook</h1>
<p>
    <asp:Table runat="server" ID="WeatherTable" />
    <asp:Label runat="server" ID="WeatherLabel" Visible="false" Text="Weather Information Currently Not Available." />
</p>

Open in new window

0
Comment
Question by:jackmac4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 

Author Comment

by:jackmac4
ID: 22722932
Here in the default codebehind, I cannot access WxControl properties. They are not available.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace PANDK
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(ReadCookie("PANDK_Location")))
            {
                
            }
        
        }
 
<<< snip >>>

Open in new window

0
 

Author Comment

by:jackmac4
ID: 22722947
finally, here is the main page code
<%@ Page Title="" Language="C#" Trace="false" MasterPageFile="~/PK.Master" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="PANDK.Default" %>
<%@ Register TagPrefix="Wx" TagName="Viewer" Src="~/ctrl/WxViewer.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="Weather" class="sectionHeaderBig">
        <Wx:Viewer id="WxControl" runat="server" latitude="36.41" longtitude="-97.89" width="465px" areaName="Enid" />

Open in new window

0
 

Author Comment

by:jackmac4
ID: 22725470
Am I not making sense or is there some clarification I could give to help someone help me?
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 14

Expert Comment

by:Ramuncikas
ID: 22728381

WxViewer myControl = (WxViewer)this.Content2.FindControl("WxControl");
myControl.latitude = "10";

Open in new window

0
 

Author Comment

by:jackmac4
ID: 22730316
Yes, this would be the way to do it if it worked - but WxViewer class isn't showing up. I cant access it. I can access the WxControl control, but the properties aren't showing up.

I'm using VWD2008.
0
 

Accepted Solution

by:
jackmac4 earned 0 total points
ID: 22731351
I found the problem - I was using an older style user control without a codebehind. Once I rewrote the control with a codebehind everything seems good.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question