Monday, October 25, 2010

Server-side button click - client side implementation

Recently, I had to override the server-side button OnClick function for a button but unfortunately and I hope you do NOT come across this scenario, but the source code file, the C# file went MISSING.

Yes, I could have use DotNet Reflector to recover the code but I was under a very quick deadline, so here is my approach.

Use jQuery!

What you have to do is to assign a unique CssClass name for the button, which can still be done with just the .aspx file.

And include jQuery as per normal the crucial part is when you declare the jQuery document.ready function, include the following within the document.ready function.

That way, you override the ASP.Net page life cycle, thus when you click the button, this code snippet runs first.

$("input.[insert_unique_css_class_here]").click(function() {
//Validate some other controls. You will have to implement the validateChkBox and validateDdl functions.
var postBackRequired = false;
var postBackIfCbChecked = validateChkBox();
var postBackIfDdl = validateDdl();

if (postBackIfCbChecked && postBackIfDdl) {
postBackRequired = true;
}

return postBackRequired;
});

Wednesday, October 6, 2010

Repeater Paging - Paged Data Source

Recently I was experimenting with paging and repeaters and managed to solve it with a PagedDataSource object.

There are certain rule that come with this, however.

After instantiating a PagedDataSource object, it is PIVOTAL to set the DataSource property directly after it, before using other properties of the PagedDataSource class.

The way I implemented it was as follows.

Have 1 repeater that will contain the list of data that would like to display.

Also, I've used a repeater approach to implement the paging numbers rather than having just the 1 page number and having 2 links that will go forward and backward.

I've also maintained the page number using a public property with ViewState holding the value of the current page.

Thursday, September 9, 2010

Javascript Pop-ups : Cross browser

http://www.quirksmode.org/js/popup.html

This site shows a good clarification between cross browser JS

Monday, August 30, 2010

SQL Server role and manual admin

I had to create a fresh instance of database for work and had to assign roles. However, I didn't want to use the "click, click, click" method but rather like to type on the query window.

NOTE: This is to be done after you've created a Database and I won't go into details as to how to create a Database or how to add a user to the database.

I retrieve info from MSDN TechNetabout the database roles and are as such.










































Database-level role nameDescription
db_ownerMembers of the db_owner fixed database role can perform all configuration and maintenance activities on the database, and can also drop the database.
db_securityadminMembers of the db_securityadmin fixed database role can modify role membership and manage permissions. Adding principals to this role could enable unintended privilege escalation.
db_accessadminMembers of the db_accessadmin fixed database role can add or remove access to the database for Windows logins, Windows groups, and SQL Server logins.
db_backupoperatorMembers of the db_backupoperator fixed database role can back up the database.
db_ddladminMembers of the db_ddladmin fixed database role can run any Data Definition Language (DDL) command in a database.
db_datawriterMembers of the db_datawriter fixed database role can add, delete, or change data in all user tables.
db_datareaderMembers of the db_datareader fixed database role can read all data from all user tables.
db_denydatawriterMembers of the db_denydatawriter fixed database role cannot add, modify, or delete any data in the user tables within a database.
db_denydatareaderMembers of the db_denydatareader fixed database role cannot read any data in the user tables within a database.

Wednesday, August 25, 2010

hMailServer

We experienced some issues with the IIS SMTP server recently at my work. The following is a description and may you say shameless promotion to a free email server for team at Redmond.

hMailServer is a free e-mail server for Microsoft Windows. It's used by Internet service providers, companies, governments, schools and enthusiasts in all parts of the world.

It supports the common e-mail protocols (IMAP, SMTP and POP3) and can easily be integrated with many existing web mail systems. It has flexible score-based spam protection and can attach to your virus scanner to scan all incoming and outgoing email.

http://www.hmailserver.com/index.php?page=functionality

Saturday, August 21, 2010

IE Tester

I know how web developers dislike the browser from Redmond, however, there is a simple tester that can be downloaded and basically allows you to test how your page renders in Internet Explorer.

Click here -> IE Tester

Saturday, August 7, 2010

Light musing - deep thoughts

“It is not the critic who counts; not the man who points out how the strong man stumbles, or where the doer of deeds could have done them better. The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood, who strives valiantly; who errs and comes short again and again; because there is not effort without error and shortcomings; but who does actually strive to do the deed; who knows the great enthusiasm, the great devotion, who spends himself in a worthy cause, who at the best knows in the end the triumph of high achievement and who at the worst, if he fails, at least he fails while daring greatly. So that his place shall never be with those cold and timid souls who know neither victory nor defeat.”
-- Theodore Roosevelt, 26th President of the U.S of A