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

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

How to Fire events on SharePoint DateTime Control in visual web part

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :SharePoint
Hi All, I am working on visual webpart of SharePoint 2010. I am using a <SharePoint:DateTimeControl> i m trying  to fire OnDateChanged event on it. I am not getting the Appropriate way to create the event. please help me out!!!!   void ToDate_OnDateChanged(object sender, EventArgs e)         {                         if (ToDate != null)             {                 DateTime min = Convert.ToDateTime(FromDate.SelectedDate.ToString());                 DateTime max = Convert.ToDateTime(ToDate.SelectedDate.ToString());                 int noofdays = Convert.ToInt32((max - min).TotalDays);                 txtNoOfDays.Text = noofdays.ToString();             }         }    <SharePoint:DateTimeControl runat="server" Calendar="Gregorian"  

View Complete Post

More Related Resource Links

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Sharepoint 2010 power tools visual sandboxed web part issue!!


Hi guys

I tried to use a simple hello world web part with with sharepoint power tools the solution is added ok but when I try to add the web part to the page I get this error "Unable to load assembly group. The user assembly group provider...." Any thoughts






Using Web Service in SharePoint 2010 Standard Web part using Visual Studio 2010

Hi All,               Have an issue with  Web service in calling  by SharePoint 2010 Standard Web part using Visual Studio 2010. If you can tell where I went wrong or tips to solve this would be great for me. What I have done is like this.. 1) Created new 'Empty SharePoint' project : as Farm solution 2) Added Web parts 3) Trying to add Web Service : There was no option for adding Web Service , so added as 'Add new Service' , this created entries in app.config file 4) ServiceName : shown as name space  (what  I'm  expecting is as Global  object with all methods ) 5) Created Object of namespace.ServiceName.ServiceSoapClient and tried to call one of it's method 6) Build and deployed 7) While viewing that web part it is showing an error as [InvalidOperationException: Could not find default endpoint element that references contract 'SerialKeyService.ServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.]         Error in detail : [TargetInvocationException: Exception has been thrown by the target of an invocation.]   at System.RuntimeTypeHandle.CreateInstance(RuntimeType t

validate sharepoint datetime control

Hi   i am using sharepoint datetime control. i need to validate  user entering past date. (should not allow).   <asp:CompareValidator ID="Comparevalidator1" runat="server" ErrorMessage="The date must be greater than today"                                     ControlToValidate="dtExpiryDate" Operator="LessThanEqual" Type="date" ValueToCompare='<%# DateTime.Now.ToShortDateString() %>' />   The above code throwing error.   Rgds, Vinay

validate sharepoint datetime control

Hi   i am using sharepoint datetime control. i need to validate  user entering past date. (should not allow).   <asp:CompareValidator ID="Comparevalidator1" runat="server" ErrorMessage="The date must be greater than today"                                     ControlToValidate="dtExpiryDate" Operator="LessThanEqual" Type="date" ValueToCompare='<%# DateTime.Now.ToShortDateString() %>' />   The above code throwing error.   Rgds, Vinay

ObjectDataSource Control Disabled/not appearing in Toobox for Visual Studio 2010 SharePoint Project

  1. I've created a SharePoint Project in Visual Studio 2010.
  2. Added Visual webPart .
  3. In the usercontrol of the webpart in trying to add ObjectDataSource control, but this control is not availble in Tool box under Data tab. it appears only if i right click on datatab and select "Show All", but still the ObjectDataSource Control is Disabled and even i cannot drag and drop it on the Webpart.
  4. Also i've created a sample Business Class, with all the mandatory attribute like





Sharepoint 2010 Visual Web Part - Personalizable


I have a visual web part which has 2 public properties

One is webbrowsable and the other is not.

I can retreive the data from the properties into the usercontrol and display them, but i'm unable to update the value and store it against the webpart, just as i would from the editor section.


Here are my 2 public properties.

 <Personalizable(), WebBrowsable()> _

    Public Property myString() As [String]


            Return m_myString

        End Get

        Set(ByVal value As [String])

            m_myString = value

        End Set

    End Property

    Private m_myString As [String]



    <Personalizable(PersonalizationScope.Shared)> _

    Public Property myStoreage() As [String]


            Return m_myStorage

        End Get

        Set(ByVal value As [String])


Custom web part properties are not saved in SharePoint 2010 visual web part


I have created my first visual web part in SP2010.  In 2007 version I didn't use user controls so all of my code was in a single file for the most part.  Now I've separated out the code.  Everything works great and I like this a lot better (more like traditional ASP.NET development) with one exception.  In my bootstrap .cs file (I call it that because it does nothing but load the user control file) I put all of my custom web part properties.  Then in my web part code-behind I reference them thru an instance of the containing class.  I must have something incorrectly configured because none of the changes to the properties at runtime are getting updated in the code.  Here's a filtered view of how I have it wired together:

Sample property in the top level .cs file:

private string m_ImagePath = "sites/myapp/images1/branded_image.png";
   WebDisplayName("Relative path to header image"),
   WebDescription("Relative path to header image"),

Get context to a control in web part from visual user control


I have a Visual Web Part (lets call it "ABCWebPart").

I'm attempting to create a connection to another web part which means I have to create the ConnectionProvider in the WebPart class (ABCWebPart.cs).

The value I want to set in my AJAX provider interface is a control I created in my visual user control (ABCWebPartUserControl.ascx).

How do I get the context of the TextBox control from my Visual user Control in order to assign it's value into the AJAX provider interface?


Thanks in advance,

- Eric

Visual Web part with embedded User Control, fields are null


I have a legacy ASP.Net application that consisted of a series of ascx user controls which I am attempting to convert into visual web parts.  

I have wrapped each ascx in its own visual webpart and deployed to my site. Within my site I am able to add some of these to my pages and they render properly.

The ones that I am having difficulty with are those ascx user controls that have a child reference to other custom user controls.

For example I have CustomerinfoUserControl.ascx that has many fields within the control, but one is also a custom user control to select the date called DatePicker2UserControl.asx

Here is the declaration within CustomerInfoUserControl  and usage …



SharePoint DateTime control returning current date when no date is selected

In WSS 3.0, I am using sharePoint DateTime control. I retrieve the date selected by the user using SelectedDate property of the sharePoint DateTime control.

The issue is that even when the user has not selected any date in the sharePoint DateTime control, the SelectedDate property of the sharePoint DateTime control returns current date. I guess it should return DateTime.MinValue or null when the user has not selected any date in the sharePoint DateTime control.

Kindly clarify.


Calendar Web Part for SharePoint that displays and gives fetails of events from an event list: Value

Hi All,

         I have followed the following post to create the custom Calendat webpart, that displays the details of events from events list. 

But i am getting the following error when i click on the dates shown as there are some events. The error looks like the following,

Server Error in '/' Application.

Value does not fall within the expected range. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Value does not fall within the expected range.

Source Error: 

Session Events of Global.asax doesn't fire in sharepoint

As I have some requiremnt, i've written some code in session_start and session_end events in global.asax of the sharepoint web applicaion. But the events don't fire when the user logs in or logs out. Even the application_start also not working when the application starts. So do i need to make any changes in web.config or anywhere ? Please help.

visual web part in sharepoint 2010



I have created a visual web part in visual studio 2010 and i can deploy it directly to my local site but i was wondering that how do create a wsp out of the project and hand it over to sharepoint admin..i don't see and wsp option over there ...do i need to install some additional thing..please can someone help me out with this.



SharePoint DateTime control validation



In the Visual web part, i have added few sharepoint datetime controls.


        <td>             <asp:Label ID="lblBirthDate" runat="server" Text="Birth Date"></asp:Label>
           <SharePoint:DateTimeControl ID="DteDOB"  DateOnly="true" IsRequiredField="true" runat="server"  />
            <asp:CompareValidator id="valDOBDate" runat="server"
          ErrorMessage="Please enter an valid d

3 Simple Steps to Create a Visual Web Part in SharePoint

SharePoint Web Part is basically a reusable component designed for a particular task and can be easily added to a SharePoint page for customization/personalization. But for me as a developer, its a user control that is deployed at Site Collection level so that all sites under the site collection can reuse it.

Short Overview of SharePoint Features in Visual Studio 2010

As you probably know, Visual Studio 2010 was announced earlier this week and it contains a lot of cool features and project templates for SharePoint developers. Below is a short overview for some of the SharePoint development related features and project templates.
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