Thursday, February 19, 2009

Dotnetnuke: how to force dotnetnuke to send welcome e-mail as HTML not plain text

To force dotnetnuke to send welcome e-mail as HTML, you just have to modify MAIL_USER_REGISTRATION_PUBLIC_BODY.Text or EMAIL_USER_REGISTRATION_PRIVATE_BODY.Text strings in language editor. DNN Framework check if the mailbody contains html code and send e-mail in corresponding mode.

Wednesday, February 18, 2009

How to show name of sender before the e-mail address using ASP.Net MailMessage object

How to show name of sender before the e-mail address using ASP.Net MailMessage object? It's very simple. Just look at following example:


System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
message.From = new System.Net.Mail.MailAddress("admin of TEST.COM <admin@test.com>");


That code was used in writing website Краш-тесты автомобилей

Thursday, February 5, 2009

How to change in code the title of web page in Dotnetnuke based website?

In the ordinal web page to change programmatically the title of the .aspx page is simple:


protected void Page_Load(object sender, EventArgs e)
{
this.Title = "The ordinal web page";
}


In dotnetnuke's module that code will not help. The title of the web page will be created by DNN's core.

But we can solve this problem. The code below shows how to achieve this:

Tuesday, February 3, 2009

LINQ to SQL: How to get a Random Record from a Table inside the SQL Server Database

I wanted to get a random record from a particular table on the SQL Server database. For my case, I had a table containing quotes, and I wanted to randomly pick on to show on one corner of my web site. I am also using LINQ to SQL for this web site, so the solution here will be using LINQ, although the approach is pretty simple and flexible.

The idea centers on ordering the records by a random parameter an then getting the TOP n number of records. The NEWID() function from SQL Server makes a great candidate for getting a random parameter since this method generates a GUID.

In SQL Server, try out this query.


SELECT * FROM Quote ORDER by NEWID();


SELECT TOP 1 * FROM Quote ORDER by NEWID();