I have a modalpopup inside it I have checkboxes,when I check the checkboxes and save the changes there is a dynamically created table with dynamically generated labels.I have a checkbox Birthdate inside the modal popup which shows the mm/dd only.And another checkbox below it that will show the year only, and will be visible if Birthdate checkbox is checked.
I want to show that if Birthdate checkbox is checked and the save button is clicked then insisde the dynamic table it will show the mm/dd only.And if year checkbox is checked ,and the save button is clicked, then it will show the Birthdate inside the dynamically created table as mm/dd/year.
I have a modalpopup inside it I have checkboxes,when I check the checkboxes and
Share
seems like there’s multiple questions here – not sure which one(s) you’re asking.
1) how to format a date in format X or Y?
– You can use String.Format(“{0:MM/dd}”, yourDateTime) or yourDateTime.ToString(“MM/dd”) or whatever for that case. Add on /yyyy for the other case.
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
2) how to conditionally display format?
– various ways, but a simple one that I think would work fine is to just add into Page_Load the check, so something like: string format = cond ? “MM/dd/yyyy” : “MM/dd”; and then checkbox.Text = yourDateTime.ToString(format);
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkbox.text.aspx
3) how to get the display to change on checkbox change?
– #2 combined with adding AutoPostBack=true on your checkbox(es)
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.checkbox.autopostback.aspx
If you can further clarify the question, in particular what parts of what you’re trying to do you’re having trouble with, it may help us provide better answers 🙂