.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Accessing variables containing usercontrols in a partial class

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net

Hello everyone,

Last night you guys here on this forum helped me in accessing properties of a dynamically loaded UC in an aspx page. Now i am facing another hiccup.

My code behind is : public partial class SiteUserControls_Message_Messages : BaseControl

In one of the click events i am loading three web users controls:

protected void RadTabStrip1_TabClick(object sender, RadTabStripEventArgs e)

         SiteUserControls_Message_Create CreateNewMessageUC = Page.LoadControl(CreateMsgControl) as SiteUserControls_Message_Create; // typecasting the UC


Now i want to access this variable CreateNewMessageUC in another event like this:

protected void MarkAsUnreadLinkButton_OnClick(object sender, EventArgs e)




In My effort to make the UC variable global i have put that in class body liek this

public partial class SiteUserControls_Message_Messages : BaseControl

       SiteUserControls_Message_Create CreateNewMessageUC;


But when i access teh variable in another event i

View Complete Post

More Related Resource Links

Accessing Functions from a Class



I am a PHP developer and am running into a lot of issues with C# and .NET. I would like to be able to do the following in C#. (i'm not sure if it should be done this way though)

C# File:

using System;
using System.Data.Odbc;
using System.Data;
using System.Configuration;

partial class site_functions : System.Web.UI.Page

protected void Main(object sender, EventArgs e)

public static void open_database()
OdbcConnection myConn;
OdbcDataReader MyReader = null;
string strConnection = ConfigurationSettings.AppSettings["dbConnect"];

myConn = new OdbcConnection(strConnection);

public void close_database()

public void Read_Database()
//do something


<%@ Page Language="C#" CodeFile="site-functions.cs" Inherits="site_functions" ContentType="text/html" ResponseEncoding="utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "

BinaryFormatter, SortedSet base class and a few instance variables.

/* This example successfully serializes and deserializes the SortedSet<string> base contents, but all the instance variables show up uninitialized. Here's the output: n1: 0 n2: 0 str: s == "String 1" s == "String 2" s == "String 3" Any ideas? */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization; using System.IO; [Serializable] public class MyObject : SortedSet<string> {     public MyObject() : base() { }     protected MyObject(SerializationInfo info, StreamingContext context)         : base(info, context)     {     }     public int n1 = 0;     public int n2 = 0;     public String str = null; } namespace BasicBinarySerializationInheritanceFromSortedSet {     class BasicBinarySerializationInheritenaceFromSortedSetTest     {         static void Main(string[] args)         {             {                 MyObject obj = new MyObject();   &nb

Sharing of Non-Static member variables of a class using .NET Remoting

This kind of weird. I am trying to host an object of a class X (a class library class). This is a SAO and I have set the WellKnownMode as Singleton in the server configuration. <wellknown mode="Singleton" When multiple clients fetch the instance of the class X they can share the static member variables. Any changes made to the static variables are visible to each other. The problem is with the non-static member variables of the class. Each instance is having a local copy of the non-static variables. Why should that happen in case of a Singleton mode? Am I missing something for which this is happening? Any help will be appreciated.  A for apple, B for boy, C for c++

accessing package level variables in a Script Component in 2008 version


how to access the package level variables within a script component in SSIS 2008

cant access class variables


hi all see the code below

using System;

 class mymainclass
    int a;
    int b;

 class calculation
    public static void Main()
        calculation cl = new calculation();

        int m = cl.getresults(5, 10);

     int getresults(int a, int b)

        int c;
        c = a * b;
        return c;

    void getinput()
        Console.WriteLine("Enter first no");
       mymainclass mc = new mymainclass();
        Console.WriteLine("Enter second no");

Accessing Package variables at design time


Hello All,

I have a question relating to the variables in SSIS.

I have an existing etl package with data flow components. One of the column is System_id to identify the Source System, the package is pulling the data from.  I plan to create a component which will validate the data based on the Rules stored in the database. These rules will be accessed based on the System_id + Target combination which needs to be set by the user at design time when the component is dropped.

In design time, i want to access this System_id field for the Custom data flow component so that i can access the database table and display the available Targets for this System_id which the user can set so that i can run the rules against this data.

I understand that i cannot access the value of the data flow at design time. My question is there other way, where i can set the variable value and access it at design time ?

Please let me know







very weird method in partial class not listed in intellisense


I have created partial class for winform many times with no problem. When doing the same thing in asp.net I am stucked even with the most basic sample code:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
protected void Page

Partial Class


Is it possible to write the definition of the partial method in two partial classes?

For Example: 

Public partial class A 


      public partial void ShowName();


Public partial class A



Is it possible to define ShowName() method in both the places?

What is the difference between " public class ClassName" and " public partial class ClassName : Syst


I m new to the asp.net, my query is what is the difference between between " public class ClassName " and " public partial class ClassName : System.Web.UI.Page"?

as we already know these are the ways of defining the class,.. but my actual query is what will be the difference caused if we add ": System.Web.UI.Page" to the class name,.. as i have done some research and found that we can't use page contents without adding ": System.Web.UI.Page ",..For Example:  we can't use cookie in simple class without adding ":System.Web.UI.Pag"

Please clear me about this confusion,... 

Accessing a Java Class from within SQL Server


I have a Java Class that I want to be able to access from within a SQL Server Stored procedure.  I know you can access C# and other .Net code, but can you also access a regular Java class this way?

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

Class Diagrams

Class diagrams show the static structure of the systems. Classes define the properties of the objects which belong to them. These include:

Attributes - (second container) the data properties of the classes including type, default value and constraints.

Creating a Simple Class in C#

The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

Static Class for Beginners

In general, the members of a class can be accessed by instance of that class when they are in public, but there comes a situation to access or call members of a class without an instance and this can be achieved by declaring them as static

Accessing SharePoint 2010 Data with Server-Side APIs

Accessing SharePoint data in server-side solutions is one of the most common tasks that you will perform as a SharePoint developer. SharePoint 2010 provides powerful server-side APIs that enable you to retrieve, add, edit, and delete SharePoint data programmatically. SharePoint 2010 also includes the new LINQ to SharePoint technology that enables you to work with SharePoint data efficiently and easily.

Temporary tables in SQL Server vs. table variables

When writing T-SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have four table options: normal tables, local temporary tables, global temporary tables and table variables. I'll discuss the differences between using temporary tables in SQL Server versus table variables.

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend