Jacob Jacob - 3 months ago 32
ASP.NET (C#) Question

Trying to center calendar control in visual studio c#

I am using visual studio and programming in c# however I am facing a problem in trying to center Calendar control in a Panel

I centered everything in the panel including radiobuttons , checkboxes , textboxes but the two calendars are stuck on the left side of the panel and I can't seem to move it anywhere else on the design page

I tried Calendar.CaptionAlign Property but it didn't seem to work

Screenshot

Is there any helpful code I can use under

protected void Calendar1_SelectionChanged(object sender, EventArgs e) {


}


Thanks

Answer

You can do it with CSS. Go to Content folder in your project and find Site.css file. Then add some CSS-class for your calendars at the bottom of this file:

.calendar {
    display: block; 
    width: 200px;
    margin: 0 auto;
}

Then set CssClass property of your calendars to "calendar".