.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

Static property. how does this work?

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
I want to understand how this works? public class UtilityDate {         public UtilityDate ()         {         }           public static UtilityDate Instance         {             get             {                 return new UtilityDateFacade();             }         } public DateTime GetDate(long userId) { //SomeImplementation //which gets datetime from database }  }     What heppens when i say   UtilityDate     .Instance.GetDate(1); Thanks 

View Complete Post

More Related Resource Links

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.

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

Server-side validation on an Entity Framework required field (property) does not work!

Has anyone had issues getting server-side validation on an Entity Framework required field (property) to work? The data type is a string (nvarchar). Server-side validation for required fields of other data types WORK fine. Only string fields have issues. I get the following error on UpdateModel(obj); of my POST method within the controller. Exception Details: System.Data.ConstraintException: This property cannot be set to a  null value.Source Error: Line 4500:                OnTextChanging(value);Line 4501:                ReportPropertyChanging("Text");Line 4502:                _Text = StructuralObject.SetValidValue(value, false);Line 4503:                ReportPropertyChanged("Text");Line 4504:                OnTextChanged(); I've even tried data annotations like this but it seems to get ignored.     [MetadataType(typeof(ObjMD))]     public partial class Obj     {    

How to Set System.Windows.Controls.WebBrowser.Document Property , navigatetostring,stream DONT WORK


Hi , i search in google , bing , cuil and all of searchs provider for the solution of this problem :


I get HTML content from HTTPWebRequest(because is much requests and if i use WebBrowser control directly i get a lag and video processing unnecessary)


And i need  set System.Windows.Controls.WebBrowser.Document with this text.


"Solution" , use new methods call NavigateToString() or NavigateToStream()

BUT THIS PROBLEM , both DON'T work with <javascript src="something.js"> or <style src="something.css">

Navigates ONLY read and process content INSIDE this tags , no external files (like 'something.js')

Solution i encountred after two weeks of search

Process the text and replace the files by the content of that.

But this i think that is no real solution. (i tested , work , but not perfectly) * I write my own code because that post dont have source code.

for why you need to do that?

because i need interact with users after search , and use html's input to re-search again and process this file with all extern files is too slow

Any solutions?

C# Lenguage

Sorry for bad english, i'am brazilian.


Cannot seem to get the Named tab property to work in R2

I went to a class and saw how to do it. It looked simple enough. But some reason i cant get mine to work. I have put in a name to test out the pagename properties of a tablix, but it does not show up on the tab when i export to excel. I also dont see where the RENDERFORMAT property is. Can anyone help, i have searched online, and see samples, but when i try it , it does not work. Will this not work with 2008 files that were upgraded to 2008 R2?

don't apply static hover style to siteMapNode that has an empty url property



I was wondering if there is any way to not apply the static hover effect to asp:menu items where their corresponding sitemapnodes don't have a url specified?

It sounds a little confusing so I thought I'd add snippets of what I'm trying to do:

I have a sitemap file with 3 levels:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="~/default.aspx" title="SOME TITLE"  description="">
    <siteMapNode url="" title="Admin"  description="" roles="Admin">
      <siteMapNode url="~/admin/userMgmt.aspx" title="User Mgmt"  description="" />
      <siteMapNode url="~/admin/roleMgmt.aspx" title="Role Mgmt"  description="" />
    <siteMapNode url="" title="Users"  description="" roles="User">
      <siteMapNode url="~/Users/MyAssignments.aspx" title="My Assignments"  description="" />

I then have my sit

lifespan of a property inside a static class in IIS



I want to know , how good / bad is it to save configuration values in a static properties?

I am creating an application which reads configuration from an XML file and a DataContext file, instead of sending the CustomConfig class into the configuration.xml each time I tought about using an ReadXml() method on application_start at the global.ascx

the ReadXml() method would save the data in static properties of CustomConfig and whereever I would want to read that particler data I would ask CustomConfig.PROERTY_NAME

My question is ? how smart it is ? how long does IIS would save the data in a static member? (if as long as the application exists then I'm ok as long as I add the ReadXml() in the application_start)

would like to hear your comment.. 

DataGridColumn CellStyle doesn't work. > The Property Setter "IsReadOnly" cannot be set because it


hello i have the folowing DataGridColumn:

<DataGridTextColumn Header="Number of pipes:" Binding="{Binding Path=Pipes.Count}">
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="IsReadOnly" Value="True"></Setter>


But I get the following error: The Property Setter "IsReadOnly" cannot be set because it does not have an accessible set accessor.


Can anyone help me out ?

Manage user Properties - Changed property "work phone" Property mapping for Synchronization but user


Hi, I've changed the a user profile settings in CA (see below) so it is no longer mapped to AD, but when I edit the user profile in SharePoint MySite I have a yellow triangle with an exclaimation mark that states "indicated a filed that is updated automatically from the corporate directory. Changes to these properties may be lost. But I have removed the mapping as above. Am I missing some thing or is there a job that I need to run to carry the update through.   

I made the change in  - "user profile service application - manage user properties - Work phone" I have removed the "property mapping for Synchronization" so it now displays "There are no items to show in this view" - Do I need to make further changes to carry this through? 

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

RadioButton inside GridView, How to get it work as normal

Did you tried before to drag a RadioButton control inside a Gridivew templatefield, and then you attempt to select these RadioButtons , you will notice that the behavior of RadioButton control will be changed and it will work just like the behavior of checkbox control! the user will be able to select more than one radiobutton in the grid!

WPF / Silverlight tutorial: Visibility property and binding

Visibility property is a very powerful and yet often overlooked property available in both WPF and Silverlight. It enables you to set Visibility of certain UIElement objects to different states like: Visible, Collapsed and Hidden (not supported by Silverlight). This tutorial shows you how to use it and how to bind to Visibility property

Get pixel format, raw format, property id list and property items image in VB.net - C#.net.

n this simple article you will learn that how we can get pixel format, raw format, property id list and property items image in VB and C#.net.

Get Pixel Format:

Image consists of pixels to get the format of the pixel we have a property named pixel format. This property returns an enumeration of pixel format. This enumeration tells the pixel format.

To demonstrate make a window application. Drag one button and a picture box on form.

Now write the following code on Button click event:

Looking for guidance: wanting to work with AJAX architecture



I'm starting a small website that will be backed by a database, and will allow a small number of users to authenticate and select an entry in the database, and then view (and optionally update) a corresponding entry (think master-detail).

I have some flexibility in how I'll do this, but I'd really like to incorperate some newer AJAX style coding, eliminating some page postbacks. I think this is a great opportunity to learn the concepts well.

I'll probably go with an ASP.NET 4.0 site. From what I've seen there are MANY ways to go about this:

-WCF Data Services to expose the data, and consume in ASP.NET

-Page methods to expose the data, separate method to update the data

-I'd rather avoid the UpdatePanel because I'm really looking for a full hands-on approach, with learning client side scripting being an objective as well.

Beyond that, it seems that one can use jQuery to build clientside templates, but also one can use the ASP.NET AJAX template engine (in ASP.NET 4.0 I believe).

A concern I have: users should only be able to work with the data exposed via these endpoints if they are logged into the website. Hopefully I can somehow reuse the ASP.NET forms authentication cookie for this purpose. 

Well, I hope I've posted enough to a

animate effect work but the render items are messed up.


Hi all,

     I have a very unique problem, humm i think. I am using a jquery effect that animate bounce effect, i have a line in my javascript pageLoad function $("#UserBrowserInfoDIV").show('bounce'); - the effects run smoothly but what it does is mess up the bolded text in the div. I have try the items inside the div without bolding and it works fine and no render problem but when bolded the text that are bolded is quite messed up, and barely readable.

Please let me know is there anything else i can do i really would like use this effect.

P.S all the effect have the same render problem, and i am using ie8 under compatibility mode.





Jscript error: Object does not support property or method


 Hi, i have little knowledge on javascript but i need to use this code get from somewhere for a jquery to work.

I face this "Jscript runtime error: Object does not support property or method" whenever im trying to run this page.

In my experience, im get this error msg 9 out of 10 times i use javascript in my system.

Im using Microsoft Visual web developer 2008, i wonder if this is related to my problem, i not sure there is anything i need to add as reference or update anything.

But anyway, in short, i just couldn't use javascript code when using this development tool because of this sort of error.

Anyway, it happen that last time i tried use the same type of jquery code in another project and it seems to work well without an error.

But now when im try to use it again in this recent project i created, it come out with this error and i have no idea how to solve it even look through google and this forum.

It doesn't really seems like its the code problem itself although im not sure, because any javascript code just couldn't work.

So below is my code that i need to use.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
<script type="text/javascript" src=&quo
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