July 2008 - Posts
When you add the Aajx toolkit controls to your visual studio toolbox , the items will be added randomly and they will not be sorted, and so you will have many related controls like accordion and accordionpane where not adjacent ! see the image below :

In The mean time :) , you can sort them by right clicking on the ajax Toolkit tab and select "Sort Alphabetically " like image below :

Regards,
You may wonder how to hide some days in the ASP.NET standard calendar control. for example if you want to hide the week end days ( Saturday and sunday) , you can simply handle the DayRender event which is called for every day in the calendar control :
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.IsWeekend Then
e.Cell.Controls.Clear()
End If
End Sub
and you may want to hide the days that is older than the current day :
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date.Date < DateTime.Now.Date Then
e.Cell.Controls.Clear()
End If
End Sub
Also Instead of hiding the days ,you can just make them un Selectables :
Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
If e.Day.Date.Date < DateTime.Now.Date Then
e.Day.IsSelectable = False
e.Cell.ToolTip = "sorry , You can't select this date ! "
End If
End Sub
The Calendar control is a good choice when you want to filter some records based on the selected date in the calendar ( when the postback is required ) , but in the the Places where you just want to provide a date selector and there is no need for the postback , Its better to use the Caneldar Extendar ajax toolkit control .
Hope it help
Anas Ghanem
In ASP.NET 2.0 and Newer versions , the readonly TextBox will ignore the submitted text , this change due to security reasons .
However , assume you have a readonly textbox and you are going to change its value on the client side ( via script) , Now how you will get the changed value on the server side ? One option is to disable the textbox control ,and set "SubmitDisabledControls" for the form to true , but this is not always a solution .
For example you want to use the Calendar extendar with the textbox and you don't want to let the user to change the textbox manually , instead you want to let the user select the date via the calendar extendar. now the problem is that the selected date will not be accepted by the textbox when the user submit the form , because the textbox is in readonly mode , in this case you need to manually set the submitted textbox value , you can easily use the values that is submitted via form collection ,
something like this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = Server.HtmlEncode(Request.Form(TextBox1.UniqueID))
End Sub
There is also many solutions other than setting the textbox as readonly , for example you can cancel the onCopy,onPaste,onkeyup all the required javascript events .
Regards,
Anas Ghanem
When configuring a custom providers , or registering HttpHandlers and HttpModules , or using any other configurations sections that needs to specify the type settings attribute , you will need to correctly specify the type by specifying a correct Namespace and Assembly .
Its not the same for web application projects (WAP) and website projects , i will discuss this difference by providing an example on how to register the httpModule .
If you are not familiar with HttpModules and HttpHandlers , please read this
Also if you are not familiar with the Differences between WAP and website project , Please read this and this
Now , lets talk about the Difference :
For WebSite project :
when you are writing a custom HttpModule in App_Code folder that is inside your website,Then you can register the Custom module in web.config in this format:
so for example if you write this module in App_Code
Then you can register that module in web.config as follows:
For Web application Projects (WAP) :
Now,when you are working with web application Project ( or VS 2003 web application ),
Then you need to PrePrend the WebApplication Name(Actually the Root NameSpace of the Project) before the HttpModule Class Name as follows:
When The module Or Handler Written in a separate Class Library:
when you need to register a custom HttpModule that is written in a separate class library , then you need to use the following format :
In this Blog post i mentioned the correct way to specify the Type attribute when working with Web application Project, Website project, and Custom class library project.
Finally , if you didn't specified that correctly , you will get this exception :
"Could not load file or assembly or one of its dependencies "...
Hope that Helps
Anas Ghanem
I noticed there is a lot of articles that is specified an incorrect images path that only works in IE , those articles used the backslash ("\") character in the Images paths , note that using backslash in the images URL is incorrect ! instead we must use the slash ("/") , for example
this image will not be recognized by Firefox :
<img src='\images\left.gif' ....
instead it must be
<img src='/images/left.gif' ....
what about asp:Image ?
if you used the backslash in the asp image control , the run time will change it to slash if and only if you used a relative image path , for example
<asp:Image ID="Image1" runat="server" ImageUrl="~\images\left.gif" />
will be rendered as
<img id="Image1" src="images/left.gif" style="border-width:0px;" />
Of course the same rule applies when specifying the image URL in the style sheets , for example when settings the Background-image attribute ,
background-image:url(images/left.gif);
Hope it Helps
Anas Ghanem
After i installed the sp1 beta for Visual studio 2008 and .net 3.5 i get that exception , I'm working on windows xp sp3 .
I solved that by reseting All the Code Access security policies , and then restarted the IIS.
More Posts