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

Top 5 Contributors of the Month
Post New Web Links

Why is the method Control.ChangeVisualState virtual *and* internal?

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :WPF

I'm currently implementing a custo

m DatePicker (because the standard one eliminates the time portion of DateTime) and came across the internal virtual method ChangeVisualState of Control.

E.g. the standard DatePicker overrides the ChangeVisualState method the following way:

internal override void ChangeVisualState(bool useTransitions)
    if (!base.IsEnabled)
        VisualStates.GoToState(this, useTransitions, new string[] { "Disabled", "Normal" });

Why is the method Control.ChangeVisualState internal?
It seems like a central and important spot for changing visual states, so what's the point of making it internal?

How can I define the same behavior in my derived class of Control, without being able to override this internal method of the framework?


Additionally, why is the method Control.OnVisualStatePropertyChanged internal as well?
Does this all mean that usage of visual states is reserved for Microsoft, or did I miss something?



Kasimier Buchcik

View Complete Post

More Related Resource Links

Virtual Source Code Control Systems: Promoting and Managing Projects using Visual SourceSafe


Source code control systems like Microsoft Visual SourceSafe can simplify just about any development project, and make it easier for your code to move safely among individual programmers, development teams, and project stages. Visual SourceSafe provides an object model that you can use as the basis of your own customized source code control environment. To give you an idea of what is possible, we'll walk you through the elements of a browser-based source code control system built with Visual SourceSafe, ASP, and VBScript. This simple system lets members of your team build, label, and promote individual files or entire projects, and to reverse promotions.

Ken Ramirez

MSDN Magazine May 2000

Binding an event method from a control in a seperate window

How would you bind a event method from a control back to a seperate window?  I have a ActiveX control hosted in a WindowsFormsIntegration wrapper.  That is operating in its own window along with all its events.  The properties of the control are handled by a class that defines the dependency objects (thanks Bob) to provide a view model between it and a window with controls for setting/getting those properties.  Since events constrained to Window 2, is it possible to bind the events back to Window 1?

AjaxToolkit's CascadingDropDown control is throwing Method Error 404 in Hybrid system environment (

Hi Experts, We have an Asp.net web application, which is deployed in shared hosting environment. On shared hosting environment initial request to this web application is handled by Linux server and then based on the requested page the Linux server is redirecting request to web server on windows OS. Now, in our web application, we have used ajaxToolkit's CascadingDropDown control to populate three levels of categories. In the hybrid system described above, the CascadingDropDown control is throwing Method Error 404. I would appreciate if some body can guide on how to resolve this issue. The sample of code snap shot is mentioned below. ********************************************************************* Aspx file. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <asp:DropDownList ID="ddlMajorLevelCategory" runat="server" Width="250px" ToolTip="Select Major Level Category" TabIndex="1"                            SkinID="h6BlueArial"> </asp:DropDownList>   <ajaxToolkit:CascadingDropDown ID="ccMajorCategory" runat="server" TargetControlID="ddlMajorLevelCategory" Category="M" PromptText=&qu

Is there a method that returns the control's type, such as "TextBox", "TextBlock", "Canvas", etc.,

Hello, I have a method that is passed in a FrameworkElement Ctrl.  When I use Ctrl.GetType().ToString() I get "System.Window.Controls.TextBox" or another string if a different type of control is passed in.  All I am interested in is the text after the last dot/period.  In my searching I thought I came across something that just returned the portion I'm looking for, but now can't find it. Is there a method that returns the control's type, such as "TextBox", "TextBlock", "Canvas", etc., without its parents? Regards, Robert

Calling a method on a Web User Control that is added ar runtime


Greetings All!


I have a Web Form that uses Master Pages. I only tell you this part so you understand the layers.


On the page, I have a web user control.  I can see public methods on that user control by simply calling  userControlName.PublicMethod();


However, there is a button on this page which generates additional content.  This content is based on a placeholder control and adding additional web user controls :


private void buildSubForms()
            Control subForm;
            // load in the Lesson Topic Sub Form
            subForm = LoadControl("~/siteAssets/controls/ilasLT.ascx");
            // load in the Reference Material Sub Form
            subForm = LoadControl("~/siteAssets/controls/ilasRM.ascx");


Now, on the main form, I want a submit button that will call a public method of each "subForm" that was added at runtime.


I have tried  various forms of Control C = This.Page.Master.FindControl("cpBody").Findcontrol("ctl01")... etc, but can never seen to get the right combination.

I am sure more info

Calling parent page method from user control


I looked up the  threads about  this. But I couldn't do it...

this is my method in aspx.page:

public  void MesajlariGetir()
        DataSet ds = new DataSet();

        SqlConnection con = new SqlConnection();
        SqlCommand cmd = new SqlCommand("msjlarigetir", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Kime", Session["kullaniciadi"].ToString());
        con.ConnectionString = cnnstr;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        pds.DataSource = ds.Tables[0].AsDataView();
        pds.AllowPaging = true;
        pds.PageSize = 10;
        pds.CurrentPageIndex = CurrentPage;


What's the best method to control access to documents and jpgs at runtime?


I want to be able to control access to photos and PDF documents at run time.

My site sells plans for decks, porches, sheds, etc.

I want users to be able to download the photos and documents as soon as they pay for them instead of having to wait for me to email the items to them.

What's the best way to do this?  I am using VB.net, SQL Server, and ASP.net.

I am entry level to lower-middle in my programming skills, but can usually follow along.

Thanks in advance for any help. 

Method structure like this Html.Control().Name("Grid1").Pageable().Sortable().Filterable().Groupable



I have a question about building method structure

I use a 3th party control and i like the way off adding or appending functionality to some control.

Here is an example:

 Html.SomeControl() .Name("Grid1").Pageable().Sortable().Filterable().Groupable().Render();

What i like is that you can call for example sortable first and then pageable.

Now how do you build something like this.

I create a class and create several methods. But the thing is you can only select 1 method. after that only the tostring is selectabel.

Can somebody help me out on this






Le Moustique

Need to use Fileupload control on webserver in DMZ to save to internal server share


 I've seen several posts that are somewhat similar, but no usable answers. The issue is that I need to use the Fileupload control on the asp 3.5 webserver (IIS7) in the DZM to save a file (mainly word, excel types) on a server share inside the firewall. Don't want to open up full windows access, nor use AD - also issues of what user would the website use to save the file. Not my network, so various security limits involved as well.

Other option would be for internal users (who are the ones who need the files) to access the webserver in the DMZ - same issues, but not quite as big a security issue if web server can't see inside. Again, user authentication would be an issue.

How have others solved this problem?


How to hide a method while creating custom control by inheriting WebControl?



I am creating a custom control by inheriting a server control, say LinkButton. There are properties like "BorderColor" available in LinkButton. Let's say, I don't want this particular property to be available when I create an instance of the custom control.

I want to completely hide this particular property (I don't want to override it but disable it.)

My code is as follows:

    Class MyLinkButton
        Inherits LinkButton

        'I want to hide the following method in such a way that if an object of MyLinkButton is created, the following property is not available
        Public Overrides Property BorderColor As System.Drawing.Color
                Return MyBase.BorderColor
            End Get
            Set(ByVal value As System.Drawing.Color)
                MyBase.BorderColor = value
            End Set
        End Property

    End Class

Can anyone help me with this oir provide few pointers?

OnPreRender method of GridView control


I was using a reflector and came up on this method OnPreRender() of GridView.

protected internal override void OnPreRender(EventArgs e) 
   if (this.DetermineRenderClientScript() && (this.Page != null)) 
      clientScript.RegisterClientScriptResource(typeof(GridView), "GridView.js"); 

Its calling JavaScript (GridView.js).

Can any one explain the usage of this .js file.

Can we override the file prior rendering of GridView

What is the difference between Control.Invoke(deligate) and Normal Method Call.


What is the difference between Control.Invoke(deligate) and Normal Method Call.

In which senarios we need Control.invoke(deligate) to call a method.

If any one knows please explain to me.

thank you.

Best method to get data from a datasource to a calendar control


Hello all. I am kind of running in circles here. I am building a meeting calendar and want to use a calendar control to display meetings. What I would like to do is cache the datasource, and use the calendar visibledate property and dayrender event to add the records to the correct days, but I can't seem to find any way to get from one to the other. Can anyone point me in the right direction here?

Internal Error 500 while running web method remotely using AJax



I got the 500 error when I run a web method remotely (It's fine if I run it locally on the server.)

The code I am using is as following:

 xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
 sParameters = "SolutionName=" + SolutionName;

After xmlhttp.send the xmlhttp status is 500.

I checked the event log on the server:

Exception information:    
Exception type: InvalidOperationException 
Exception message: Request format is unrecognized for URL unexpectedly ending in '/RunSolution'. 
Request information:    
Request URL: http://virtualxp-55370/ws/Service1.asmx/RunSolution    
Request path: /ws/Service1.asmx/RunSolution 
User host address:
Is authenticated: False    
Authentication Type:  
Thread account name: VIRTUALXP-55370\ASPNET
Thread information: 
Thread ID: 1&nbs

Gmail internal chat like message box

This article provides you with the multi-functional message box window through which the usability of the web-site or any web application increases.

.Configurable MessageBox window with AJAX Support
.can set maximum number of message boxes to be visible
.can define the auto reload time, for single message, for all messages or no reload
.can create messages through a single function call
.can define auto hide time for each messages

Thinking about new C# method prototypes: object as dictionary

I recently had to write a small Flickr API. I know many .Net API for Flickr already exist but I needed one for a Silverlight application. Whatever, it's only about building some querystrings so I did it by myself. It's been an opportunity to think again about a classical question: how to pass parameters to a method ?

Imagine you have a generic method to call some Flickr functions.
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