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();

Friday, January 30, 2009

Remember Me not working for Login in DotNetNuke based website

The "Remember Me" feature of the DotNetNuke Login is implemented by placing an encrypted authentication cookie on the user's machine.

The expiration of this cookie is controlled through the timeout value in the Forms Autentication node the web.config.

< forms name=".DOTNETNUKE" protection="All" timeout="60" cookieless="UseCookies" />

The default setting is 60 minutes, so it can't remember anyone for very long (I call it goldfish mode).

To extend the time your users are remembered make the timeout value larger.

Tuesday, January 13, 2009

display:inline-block for Firefox, Internet Explorer and Opera

For correct displaying of the elements with display:inline-block property in Firefox Internet Explorer, Opera you have to write this in style sheet:


display:-moz-inline-stack;/*Firefox need this to simulate display:inline-block*/

display:inline-block; /*IE does not apply this to Block Element, and Firefox does not render this, too*/

_overflow:hidden;/*fix IE6 to expanded content*/
zoom:1;/*trigger hasLayout*/
*display:inline;/*once hasLayout is true, set display:inline to block element will make display:inline behave like display:inline-block*

Tuesday, January 6, 2009

How to reduce the size of the database in Microsoft SQL Server

On hosting server often exists database quota for MS SQL Server. Even if your database contains small amount of data, but there is goes intensive adding/modifacation of the data, in some point the size of the data could exceed quota and your account may be suspended.
This happens because of growth of the transaction log.
To clear transaction log you can execute the following command:

Wednesday, December 24, 2008

How to change string "You are here" in Dotnetnuke web site to other language

How to change string "You are here" in Dotnetnuke's web site to other language?

If you want to translate it, you need access to you DNN installation via file system. Look for the Skin folder (/Portals/_defauls/Skins/MinimalExtrophy) and inside there is a folder /App_localResources with a single file "index.ascx.resx" you need to copy to index.ascx.sv-SV.resx and edit using a text editor. you will find "you are here" near the end of the file and may overwrite it with your localization.

This works to DNN version 4.9 and above. How it works you may see here

Wednesday, October 29, 2008

Нow to dynamically change query for ListView linked to LinqDataSource?

In order to dynamically change query for ListView linked to LinqDataSource you have to handle OnSelecting event for LinqDataSource. .

For example:


protected void dsMates_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
if (Request.Params["classMateId"] != null)
{
int mateId;
if (int.TryParse(Request.Params["classMateId"], out mateId))
{
using (DataClassesPrivateMsgDataContext db = new DataClassesPrivateMsgDataContext())
{
e.Result = db.Classmates.Where(mate => mate.Id == mateId).FirstOrDefault();
}
}
}
}

How does it works you can see here: 11-A

Wednesday, October 22, 2008

Code formatter for C#, JavaScript, HTML, ASP.NET for your blog

When posting posts to my blog often need to insert some code saples into the text. It's good to show well formatted code for readers.

If found good free online tool for my purposes:

www.manoli.net/csharpformat/format.aspx

This tool allows you to format your C#, VB, HTML, XML, T-SQL or MSH (code name Monad) code for publishing on a web site or in a blog.

All welcome!

Friday, October 17, 2008

Animated gif files for AJAX loader

When you develop AJAX-based website you probably want beautiful animated gif image(s) to show to the user an AJAX activity (when user have to wait while AJAX is getting some data from server). So I found very useful website "ajaxload.info" where you can generate different "AJAX-loading" animated gif images. There is many templates. You can change colors, size, opacity for gif's.

If you using "Opera" than you can install wiget named "Animated loading image generator!" and generate gif's not quit your favourite website "калькулятор автокредита"

Wednesday, October 8, 2008

Dotnetnuke site constantly to recreate the domain application: "The AppDomain shut down because of the hosting environment."

I've made a site using CMS DotNetNuke. On my developing machine it worked very good. After placing It into the hosting I've noticed that pages, especially the first opened very slowly. I looked into site's Event Viewer and see that the application domain recreated several times a minute. There are consistent records:

Application Shutting Down. Shutdown Details: The AppDomain shut down because of the hosting environment.

Application Started.


Operation of Re-creation of domain application is not fast, and it leads to lower the productivity of the website (slowly loading of pages).