by bryian
12. September 2011 19:34
Yet, another social sharing buttons script created by using jQuery and XML for your website. The script is very straight forward and self explanatory. The buttons container and buttons setting are stored in the XML file.
Figure 1

Figure 2

-
Download the SocialButton.xml and jquery.social-buttons.js file. This script requires the latest jQuery library, get it at http://jquery.com/.
-
Open the SocialButton.xml and customize the necessary setting. You can customize the div container border style, width, color, position, and margin and background color. The DivMargin allow us to adjust the div container to the left and right.
Listing 1:
<!--solid, dotted, dashed, none -->
<DivBorderStyle>dashed</DivBorderStyle>
<!--Border width (int) -->
<DivBorderWidth>1</DivBorderWidth>
<!--Border color-->
<DivBorderColor>#0000A0</DivBorderColor>
<!--left, right, top, bottom -->
<DivPosition>left</DivPosition>
<!--left or right (px) -->
<DivMargin>50px</DivMargin>
<!--Div background color -->
<DivBgColor>#F9F9F9</DivBgColor>
You have the option to show or hide a particular social button.
Listing 2:
<!--none, block -->
<DisplayGooglePlusOne>block</DisplayGooglePlusOne>
<DisplayFacebookLike>block</DisplayFacebookLike>
<DisplayFacebookShare>none</DisplayFacebookShare>
<DisplayTwitter>block</DisplayTwitter>
<DisplayDigg>block</DisplayDigg>
<DisplayStumbleUppon>block</DisplayStumbleUppon>
<DisplayAddThis>block</DisplayAddThis>
-
Open the jquery.social-buttons.js file and provide the location of the XML file on your server. Use absolute link if you are not sure of the relative path and make sure the script and xml file are in the same domain. For example:
Figure 3
- Place the scripts before the body tag in the master page, template or web page that you want the social buttons to appear. For instance:
Figure 4
-
Does your script work on different platforms?
Yes, it should be cross-browser compatible.
-
How come I don't see the social sharing button that I like?
Currently, the script only provide the option to show or hide Google Plus One, Facebook like/Sharing, Twitter, Digg, StumbleUpon, and AddThis buttons. You can modify the script to fit your requirements.
-
Is this script free?
Yes. Use at your own risk.
-
Why there are white space in between the button?
Some buttons do not display the counter if the count is zero.
I hope someone will find this information useful and make your programming job easier. If you find any bugs or disagree with the contents or want to help improve this article, please drop me a line and I'll work with you to correct it. I would suggest downloading the demo and explore it in order to grasp the full concept of it because I might miss some important information in this article. Please send me an email if you want to help improve this article.
Demo
Download
by bryian
3. June 2011 12:17
A while ago, someone at the forum has asked "how to retrieve the checkbox value from the ASP.NET DataList control". I took the opportunity to put together a sample code to achieve the requirement through the Code Behind and jQuery.
In this example, I'm using HTML Input (CheckBox) control in the DataList. Shown in listing 1 is the code use to get the selected checkbox value. The code will loop through the DataListItemCollection, find the CheckBox control by ID then do something if it was checked.
Listing 1:
void GetCheckedBox()
{
foreach (DataListItem li in BooksDataList.Items)
{
HtmlInputCheckBox cb = li.FindControl("FavChkBox") as HtmlInputCheckBox;
if (cb != null)
{
if (cb.Checked)
{
if (LblText.Text.Length > 0)
LblText.Text += ", ";
LblText.Text += cb.Value;
}
}
}
}
Let's say we decide not to write code to loop through the DataListItemCollection, we can collect the selected CheckBox value through the client-side script. Shown in Listing 2 is the jQuery script use to collect the selected CheckBox value. When the user hit the submit button, the script will retrieve all the CheckBox value in the DataList control, stored in an array and later save it to a hidden field.
Listing 2:
<script type="text/javascript">
$(document).ready(function () {
//check all
$("[id$='chkAll']").click(
function () {
$("INPUT[type='checkbox']").attr('checked', $("[id$='chkAll']").is(':checked'));
});
$("[id$='btnSubmit']").click(function () {
var ISBN = [];
$("[id$='BooksDataList'] input[type=checkbox]:checked").each(function () {
ISBN.push($(this).val());
});
$("[id$='HiddenField1']").val(ISBN);
});
});
</script>
In the code behind we can retrieve the hidden field value like this "HiddenField1.Value;"
I hope someone will find this information useful and make your programming job easier. If you find any bugs or disagree with the contents or want to help improve this article, please drop me a line and I'll work with you to correct it. I would suggest downloading the demo and explore it in order to grasp the full concept of it because I might miss some important information in this article. Please send me an email if you want to help improve this article.
Demo
Download
by bryian
27. February 2011 19:34
Several weeks ago one of my legacy web applications written in Classic ASP underwent a security scan/evaluation. The report indicated that the application contains server error response vulnerability. I had already configured the IIS to redirect the HTTP 500 - Internal Server Error to the custom error page. The users are seeing the custom error page instead of error details. So, what are we missing here? We start to debug the application by using Fiddler and found out that the application was returning status code 500 instead of 200.
Figure 1:
The report indicates that this exposure will allow the attacker to distinguish between valid and invalid request attempts. After spending some time researching for the solution, I found this article "How Web site administrators can troubleshoot an "HTTP 500 - Internal Server Error" error message on IIS 4.0 or on IIS 5.0"". The solution is to add the following line on top of the custom error page.
Listing 1:
Response.Clear()
Response.Status ="200 OK"
The first line will erases any buffered HTML output and ensure that the page is displaying a clean error page. The second line specifies the value of the status line returned by the server. Load the page that throw HTTP 500 - Internal Server Error again, and we should see the result similar to figure 2.
Figure 2:

If your website is being audited and come across this sort of situation, this could be one of the solutions. Hope someone will find this information useful.
References:
http://support.microsoft.com/kb/311766