by Admin
30. June 2009 19:09
Problem: I have been digging around on how to incorporate the SyntaxHighlighter with the BlogEngine 1.5. I am able to find tons of great article on how to install it or where to download it. But do not find many articles that “show us how to apply/use SyntaxHighlighter after the installation”. Below is a brief demonstration on how to incorporate the SyntaxHighlighter with BlogEngine 1.5 and how to utilize it.
1) Download SyntaxHighlighter 2.0 from http://sh2forbe.codeplex.com/
2) You will see two folders in the zip file namely app_code and SyntaxHighlighter. You will find SyntaxHighlighter.cs in the app_code folder, copy and paste it to your blog App_Code folder. Copy the SyntaxHighlighter folder into the root of the blog (c:\BlogEngine\ SyntaxHighlighter).
3) Log in to your blog and click on the extensions under the Control panel and unselect any brushes that shouldn't be loaded as well as choose the style to use.
4) For more information/ further reading: http://sh2forbe.codeplex.com/
5) To consume it: click on Add Entry, HTML icon

Place the code between the <pre> tag

Hit the update button after you done and below is the output from the above.

Happy coding, any comments are welcome.
by Admin
28. June 2009 18:20
A while ago, one of my friend has asked me what the different between the Dynamic/Static attribute displays of the validator control. Below is the brief demonstration of it.
<table class="style1">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Enter Number between 1 and 100: "></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Width="50px" CausesValidation="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RequiredFieldValidator"
Display="Dynamic">Required !!!</asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="RangeValidator"
MaximumValue="100" MinimumValue="1" Display="Dynamic">out of range</asp:RangeValidator>
</td>
<td>
<asp:Label ID="Label2" runat="server" Text="Enter Number between 101 and 200: "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="50px" CausesValidation="True"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox2">Required 2!</asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator2" runat="server"
ErrorMessage="RangeValidator" ControlToValidate="TextBox2"
MaximumValue="200" MinimumValue="101">out of range</asp:RangeValidator>
</td>
</tr>
<tr>
<td class="style2">
<asp:Button ID="Button1" runat="server" Text="Button" />
</td>
<td>
</td>
</tr>
</table>
The output from the above code


Explanation:
The space in the first column for the validation message is dynamically added to the page if fails.
The space in the second column is reserved / allocated for the validation control in the page layout
by Admin
28. June 2009 07:35
Sometimes we might run into an issue where the images or Style Sheet or JavaScript etc… not render correctly.
It could be very frustrating and we don’t want to hard code the absolute path to the destination files. Here are a few demonstrations on how to handle these types of situations. This is the structure of my web project.
I have these lines in my master page. The script will render correctly on the Default.aspx page. But it will not behave the same if we have a Default.aspx page in the test folder
<script language="javascript" type="text/javascript" src="js/ddaccordion.js"></script>
<script language="javascript" type="text/javascript" src=" js/jquery-1.2.2.pack.js"></script>
<iframe id="ads_frame" marginheight="0" marginwidth="0" scrolling="no" frameborder='0' src="slideAds.html"> </iframe>
Here are a few tricks I find to remedy the problem. We can use the "string Control.ResolveClientUrl(string relativeUrl)" method
<script language="javascript" type="text/javascript" src='<%= ResolveClientUrl("~/js/ddaccordion.js") %>'></script>
<iframe id="ads_frame" marginheight="0" marginwidth="0" scrolling="no" frameborder='0' src='<%= ResolveClientUrl("~/slideAds.html") %>'> </iframe>
Another alternative is to use Request.ApplicationPath + "location if the file". But make sure you leave no space between the Request.ApplicationPath and the "location if the file".
Note: this will not work because of the space
<script language="javascript" type="text/javascript" src='<%= Request.ApplicationPath %> /js/jquery-1.2.2.pack.js'></script>
This will work
<script language="javascript" type="text/javascript" src='<%= Request.ApplicationPath %>/js/jquery-1.2.2.pack.js'></script>
<iframe id="ads_frame" marginheight="0" marginwidth="0" scrolling="no" frameborder='0' src='<%= Request.ApplicationPath %>/slideAds.html’ > </iframe>
Happy coding and all comments are welcome.
by Admin
27. June 2009 21:53
Problem: I wanted to delete some files from a certain folder based on the result from a T-SQL in the Job. So, instead of calling another process/service, we try to delete it by using T-SQL. I found a very nice article out there delete file from sql server xp cmdshell ole automation procedures
I execute the following query but it throw me another puzzle
exec sp_configure
go
exec sp_configure 'xp_cmdshell', 1
-- Configuration option 'xp_cmdshell' changed from 0 to 1. Run the RECONFIGURE statement to install.
go
reconfigure
go
Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51
The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
Here is the solution I found: Problem with Context Switching feature in SQL 2005
EXEC sp_configure N 'show advanced options', N'1'
RECONFIGURE WITH OVERRIDE
EXEC sp_configure N 'xp_cmdshell', N'1'
RECONFIGURE WITH OVERRIDE
EXEC sp_configure N 'show advanced options', N'0'
RECONFIGURE WITH OVERRIDE
So, if you are looking on how to enable xp_cmdshell, your complete solution is at the top.