I was making a yearly calendar and i needed to output the cells to represent the days in the year. At first i just made a public variable, filled it up with html and then outputed it to the page like this:-
\r\n
\r\n<%=variablename%>\r\n
\r\nThis seemed to work well but the page didn”t update on postback methods because the html was being rendered before any methods were executing.\r\nI figured there must be a way to output to the current page so i had a look around and found some code that updated a panel control. To send it raw html use this command:-\r\n
I was writing dynamic form variables to the page and i needed to retrieve their values when updated. When i tried to access the variables with request.params[] collection i noticed that the keys were what id i had given them with a string appended to the start. I wrote this function to easiliy access the variables:-\r\n\r\n
\r\npublic static string PostVal(string key)\r\n {\r\n string retval = "";\r\n foreach (string s in HttpContext.Current.Request.Form.AllKeys)\r\n {\r\n string[] sr = s.Split(''$'');\r\n if (sr[sr.Length - 1] == key)\r\n {\r\n retval = HttpContext.Current.Request.Form[s];\r\n }\r\n }\r\n return retval;\r\n }\r\n
I needed to have custom colours in my project so i looked at a few controls out there and the one i chose is from http://www.obout.com/ It seemed to do the job quite nicely.’,
I have to calculate date intervals between two global dates depending on the inclusion of certain days of the week, such as monday to wednesday. All you need is two calendars and check boxes for the days of the week to include. This is the calculation for working out the dates:-\r\n
\r\nDateRangeOutput = "";\r\n string DateFrom = Date1.Text;\r\n string[] TmpArr = DateFrom.Split(''/'');\r\n int DayFrom = Convert.ToInt32(TmpArr[0]);\r\n int MonthFrom = Convert.ToInt32(TmpArr[1]);\r\n int YearFrom = Convert.ToInt32(TmpArr[2]);\r\n DateTime MasterFrom = new DateTime(YearFrom, MonthFrom, DayFrom);\r\n \r\n string DateTo = Date2.Text;\r\n TmpArr = DateTo.Split(''/'');\r\n int DayTo = Convert.ToInt32(TmpArr[0]);\r\n int MonthTo = Convert.ToInt32(TmpArr[1]);\r\n int YearTo = Convert.ToInt32(TmpArr[2]);\r\n DateTime MasterTo = new DateTime(YearTo, MonthTo, DayTo);\r\n\r\n //DayOfWeek TDay=MasterFrom.DayOfWeek;\r\n int CDay = Convert.ToInt32(MasterFrom.DayOfWeek);\r\n bool AddTo=IsDayChecked(CDay);\r\n DateTime StartDate = new DateTime();\r\n DateTime EndDate = new DateTime();\r\n bool StartDateCont = true;\r\n bool EndDateCont = true;\r\n if(AddTo){\r\n StartDate=MasterFrom;\r\n EndDate=MasterFrom;\r\n }else{\r\n StartDateCont=false;\r\n EndDateCont = false;\r\n }\r\n\r\n DateTime PointerDate=new DateTime(YearFrom,MonthFrom,DayFrom+1);\r\n int DayCount=1;\r\n while(PointerDate<=MasterTo){\r\n CDay=Convert.ToInt32(PointerDate.DayOfWeek);\r\n AddTo = IsDayChecked(CDay);\r\n if(AddTo){\r\n if (!StartDateCont)\r\n {\r\n StartDate = PointerDate;\r\n StartDateCont = true;\r\n }\r\n EndDate=PointerDate;\r\n }else{\r\n if (StartDateCont) AddDates(StartDate.ToString("dd-MM-yyyy"), EndDate.ToString("dd-MM-yyyy"));\r\n StartDateCont=false;\r\n }\r\n DayCount++;\r\n //PointerDate=new DateTime(YearFrom,MonthFrom,DayFrom+DayCount);\r\n PointerDate=PointerDate.AddDays(1);\r\n \r\n }\r\n if(StartDateCont){\r\n EndDate = new DateTime(YearFrom, MonthFrom , DayFrom ).AddDays(DayCount - 1);\r\n //alert(DayCount);\r\n AddDates(StartDate.ToString("dd-MM-yyyy"), EndDate.ToString("dd-MM-yyyy"));\r\n }\r\n\r\n
\r\n\r\nThe following code is what i do with the dates:-\r\n
We wanted to upgrade the usability of the new site we are developing, i have briefly seen info about the microsoft ajax extentions so i thought i would check it out. The main site is http://ajax.asp.net which has tutorials, articles and downloads. I downloaded the extensions for asp.net 2.0 and i also downloaded the toolkit. Now i had the code i thought i would upgrade one of my pages, i added the script manager and an update pane to one of my pages, in the script manager i set the property “Enable Partial Rendering” to true and then pressed play. The page loaded and when i clicked the submit button it submitted the form and updated the message label without reloading the page. Cool i thought this is going to be straight forward so i thought now i will check out the AJAX Toolkit. I unzipped the solution, loaded it into visual studio and pressed play. Well the build failed because the System.EnterpriseServices assembly wouldn”t load because it didn”t have the correct permissions. So off to google i went, after many unhelpful sites i figured it has something to do with the security levels in the web.config. So i updated the directive “trust” and set it to\r\n\r\n<trust level=”Full”/>\r\n\r\nI am not too experienced with windows permissions but i don”t think this is too unsafe. Anyway this got it working and i loaded the sample website. There seemed to be many cool controls and i worked out how i could use some of them in the current project. I added the tabs control without much drama but the autocomplete control is giving me trouble. What is cool about it is that it uses web services which i hadn”t done is asp.net before. They seem pretty straight forward which is great as we are going to be using them in the future. One thing i noticed about them is they don”t share the session from the ajax page accessing them.
Welcome to Developing ASP.
I have been developing dot net for about a year now, with many years experience with PHP/MySQL and for the last 3 months have been using ASP.Net. I like to give back to the community as most of my learning comes from what i can find on the web. So here we are with a site dedicated to learning ASP.Net. You can find some of previous work that i have done in PHP at http://www.developing-php.com. There is some javascript stuff there to.