Pages

Friday, June 18, 2010

Email Sending Function

Namespace :
using System.Net.Mail;

Function # 1:

public void SendEmail
_ByHostSettings(string mySubject,string myMessageBody,string Email_To)
{
MailMessage mm = new MailMessage(Convert.ToString(DotNetNuke.Common.Globals.HostSettings["HostEmail"]), Email_To, mySubject, myMessageBody);
mm.BodyEncoding = System.Text.Encoding.UTF8;
mm.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient(Convert.ToString(DotNetNuke.Common.Globals.HostSettings["SMTPServer"]));

if (DotNetNuke.Common.Globals.HostSettings["SMTPEnableSSL"].ToString() == "Y")
{
smtp.EnableSsl = true;
}
else
{
smtp.EnableSsl = false;
}

smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(Convert.ToString(DotNetNuke.Common.Globals.HostSettings["SMTPUsername"]), Convert.ToString(DotNetNuke.Common.Globals.HostSettings["SMTPPassword"])); //From user credentails
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

smtp.Send(mm);

}


Function # 2:

public void SendEmail(string mySubject, string myMessageBody, string Email_To, string Email_From, string SMTPServer, bool EnableSsl, string SMTPUsername, string SMTPPassword)
{
MailMessage mm = new MailMessage(Email_From, Email_To, mySubject, myMessageBody);
mm.BodyEncoding = System.Text.Encoding.UTF8;
mm.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient(SMTPServer);

smtp.EnableSsl = EnableSsl;

smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(SMTPUsername,SMTPPassword);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

smtp.Send(mm);

}

How to Call:

new SendEmail_ByHostSettings("TEST MAIL", "Thanks for your interest", "razarajwani@live.com");

DNN Parametrized Redirection

Function :

public string GetTabIDURL(int PortalID, string ModuleName)
{ DataTable dt = new udf.Udf().Fill_DataTable("SELECT * FROM vw_Modules where modulename='" + ModuleName + "' and portalid=" + PortalID + " and tabid is not null");

return "~/tabid/" + dt.Rows[0]["tabid"].ToString() + "/default.aspx";

}


How to Call:

protected void GoToDetail_Click(object sender, EventArgs e)
{
int JobID = Convert.ToInt32((((LinkButton)sender).CommandArgument));

Response.Redirect(new udf.Udf().GetTabIDURL(this.PortalId, "bl_JobDisplay").ToString() + "?JobID=" + JobID);

}

Wednesday, June 16, 2010

Autocomplete text box in dot net nuke

This article define how you will use the text suggestion box in dot net nuke like google, msn or yahoo websites

read this
http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryId/1067/Using-the-DNN-Text-Suggest-Control.aspx


Styles for Text suggestion Boxes
http://woork.blogspot.com/2009/02/useful-ajax-auto-suggest-scripts

HTML VS HTM

This is very simple question but i don't think many people knows about that what is the difference between HTML and HTM why these both extension are different even both contain the same code style

Ans. Three letter extension (.htm) was due to Windows 8.3 filenaming convention used in DOS because it could not understand 4 letter extensions or long filenames. html is the proper extension and should always try to use this instead of htm. in 1995 when windows 95 arrived then it will give the support for more then 3 charcter extenshion thats why .html was drived always prefer to use ".html"

Thursday, February 18, 2010

How to Install Dot Net Nuke (DNN)

:) now every one asking to how to install the dot net nuke on the live server, dedicated server or local PC

You need fulfills pre-requirments

******************************************************************************


For local PC and dedicated server
1) Configure IIS from Start > Settings > control panel > Add remove program > Add remove component >Select Inetnet Information Server then click next
(Note you need the OS cd for installation)


******************************************************************************


2)Make sure your installation drive must be NTFS

******************************************************************************


3)Down the latest .zip file from the http://www.dotnetnuke.com site

******************************************************************************


4)Extract the zip file from your NTFS folder

******************************************************************************


5)Right Click on it and Go to security tab and allow writting permission to ASP.net user (I prefer to give the wiritting permission on every one so get rid of all permission issues)

******************************************************************************



6)Click on the websharing tab with the security tab and put the virtual name also and click on the directory browsing only for the local pc

******************************************************************************


7) Create the db in sql server (for just refrence i use dnn5 here)

******************************************************************************

8) Open your web.config file and adjust the following lines
make sure each line must be in online other wise it gives you an error it silly but that is fact




For Online please do this must


it must be

Check out my other blog related other installation issues as well

******************************************************************************
9)Go to IIS and make sure following check list
a) Right click on the website virtual name and click on property
b) Select the ASP.net tab
c) Check the selected frame work will be 2.0 by default (if it is not that means your .netframework install before IIS so you uninstall the .netframework and reinstall it the problem will solve other wise it shows you an error)
d) Click on directory security tab then click on edit button under the Anonymous access section and check the permission mostly XP shows the dialog box when you execute the website on browser you will get the popup for getting user name password for get rid of this thing just Anonymous access and uncheck Integrated windows authentication in the last of the window if you still feel the same issue then create a user and select in the account and uncheck Allow IIS to control password and give you own password"

******************************************************************************
10)Now go to your browser and type http://localhost/dnn5 and the installation will auto run click on the automatic option and do next

Great now your DNN is ready and now use it

Regards

M Raza Rajwani
razarajwani@live.com
+92 322 2321301

Saturday, February 6, 2010

SQL Server Integration Service SSIS & FTP Service

Well after the long research i found the auto transfer the data from one system to other or one database to other with in very short time, well this research is based on the transfering of paradox data to the the online server via SSIS.

Well i did not found a pure solution for this issue but after a lenghtly research i found the ways that basically provide me the sucess regarding to this issue

Well the acctual project scope is transfering the paradox data from different local system to the online main website server

the scope seems to be very different and unique well we use SSIS technology for covering this thing


You need following steps to connect your local PC to the online server

1) SSIS (SQL SERVER INTEGRATION SERVICE)
2) SQL SERVER Job Agent

to be honest if the SSIS is not running propoerly then just reinstall the ssis with the propoer SQL custom instanace name because if start i have spend around a week to rectify the issue for running the SSIS but i found the misktake in the installation that we mostly use default instance in sql sever installation and that creates an issue with SSIS and speically reporting server

Well I assume that SSIS is running on your pc in healthy enviroment well let SSIS offer you the left side tool bar same like the visual studio you will select the "For Each loop Container" and double click on it and set the setting

1) General
Give the name i gave Foreach Loop Container

2) Collection
In the "Enumatrator section" D:\Data select the folder that you need to shifted

3) Variable Mapping (This important)
a) Click under the variable heading and Click on the new variable in the dropdown
in container drop down click on the package > Executable > Foreach Loop container
b) Give the name
C) leave user as it is

4) Click ok to exit

Now next is double click on ftp task in the left Toolbox option and put this ftp task under the foreach look container

once you put the ftp task under the foreach loop container then double click on the ftp task
1) General
Leave as it is

2) File Transfer
Is local variable > select true
select the variable that we define in the above steps

Now click ok and then set the connection with live ftp
Click on connect manager
click on new connection
select FTP
and set the ftp credentials

once all things set now click on (not the double click) the ftp again and put the connection manager varaible in the remote connection section

and once you run it the the ftp will shift all files in the specific folder one by one from your local pc to the remote or any other computer

you will set the scheduler by sql job agent eaisly

I hope this blog helps you if you need any further assitance then feel free to contact me at razarajwani@live.com

How to Start Web Development

Many peoples ask me what they do in their professional career, so i always give one answer to them do that what you mind and heart says and do this work very sincerely, then see you will get the success what ever you are doing.

I know that is really hard to understand for new comers same like me when i want to select one field as a professional. Lucky i got the web engineering and start my career with full of intentions.

Before starting any thing make sure your self that do you have the interest in this field from you soul, well now let start now. There are few general key point before starting web engineering

1. Always honest with your work
2. Don't loss the hope, if you did not get the solutions. Always struggle again and again
3. If you stuck and did not think the new ideas or solution then change the environment then get back to work
4. Don't look at the clock that just keep in mind that you that target and you need to achieve
5. Have a command in the tools
6. Research work involved frequently


Well always keep these point when every you start work now i informed you how you get started the web engineering what exactly you courses you need to do

  1. Study & Understand HTML (http://www.w3schools.com) is the best site ever for binning level, make sure you know the tags and functionality. there are various tools that i define in my next upcoming sections you will use these tools but make sure you know all tags and properties relevant HTML. It is important because once you do the good professional work then you need to work with the codes and CSS mostly as a result you can handle this very easily
  2. Once you finished the HTML then installed the Dream weaver or Front page as a HTML tool you will learn the basic tutorial form here
    http://www.haverford.edu/acc/docs/software/dreamweaver/welcome.htm

    or

    Check this
    http://www.vineyardesigns.com/resources/dreamweaver/

  3. After that you need move on to the look and feel of the website make sure start with the professional work so make sure you get the ADOBE PHOTOSHOP and working on it.

    http://www.photoshopsupport.com

    For creating some special effects in photoshop
    http://www.teamphotoshop.com/Tutorial-15,8.html

  4. Obviously you are new and did not know what you need to design then just get the sample here www.templatemonster.com get the idea and create a clone for study purpose make sure they have copyright laws for these template so make sure do not sale any design otherwise the website has been blocked
  5. Once you create a design in Photoshop then implement it in HTML that is the another section that i will define in next blog, now its your turn to find out how to create the templates and HTML as well as how you deploy it

I hope you got the bigning point and best wishes in your upcoming bright career

Scheduling a daily backup of sql server 2005 database using sql agent

Scheduling a daily backup of sql server 2005 database using sql agent is very easy. By following below steps anyone can do that.

1. Open sql server 2005 Management Studio and connect a server
2. Expand the tree (left navigation) ”Management->Maintenance Plans”
3. Right click on node Maintenance Plans and Click “Maintenance Plan Wizard” (As shown in figure below) which causes to open a wizard.




4. Follow the wizard

5. In 2nd step of the wizard, You can schedule the task as clicking the Button “Change” as shown in the following





6. Once you click the button “Change” you will get a new popup to enter shedule details as shown below.


7. Click OK. It will save the schedule info and close the popup. And click Next button to follow the next step.
8. In this step you will be asked to check the check list for all the tasks those can be added in mainteance plan. Select “Backup Datbase (Full)” as shown in the figure.



9. Follow the steps until you get following window. Once you get here Select one or more databases from the list of databases by clicking Dropdown for Databases.



10. From the above window, browse the folder location where to store the backup files.
11. Continue the the steps until you get to Finish step.
12. Click Finish. Once you click finish, the wizard will execute the steps to to create a job to schedule database. Immediately you will notice a job created in Sql Agent -> Jobs.
13. As per the schedule, the job runs (Repeatedly or One time) and it creates backup file with name DB_NameMMddyyyyHHmm.bak (Ex: NorthWind060420081912.bak) in the specified folder (Borwsed in the above step).

Friday, January 29, 2010

Exporting DataTable to CSV File Format


Designer export.ascx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ExportReport.aspx.cs" Inherits="Web_Crystal_Report.ExportReport" %>

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Pagetitle>

head>

<body>

<form id="form1" runat="server">

<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"

GridLines="None" style="font-family: 'Trebuchet MS'; font-size: 10pt"

Width="100%">

<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />

<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />

<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />

<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

<EditRowStyle BackColor="#999999" />

<AlternatingRowStyle BackColor="White" ForeColor="#284775" />

asp:GridView>

<asp:Button ID="btnExport" runat="server" onclick="btnExport_Click"

style="font-family: 'Trebuchet MS'; font-size: 10pt" Text="Export" />

form>

body>

html>

CODE BEHIND export.cs

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

using System.Data.Sql;

using System.Data.SqlClient;

using System.IO;

namespace Web_Crystal_Report

{

public partial class ExportReport : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

SqlConnection Cn = new SqlConnection("server=eingserver;database=DNN_5.2.2;uid=sa;pwd=eingtech");

SqlDataAdapter adp = new SqlDataAdapter("select * from users", Cn);

DataTable dt = new DataTable();

adp.Fill(dt);

GridView1.DataSource = dt;

GridView1.DataBind();

}

protected void btnExport_Click(object sender, EventArgs e)

{

#region Export Grid to CSV

SqlConnection Cn = new SqlConnection("server=eingserver;database=DNN_5.2.2;uid=sa;pwd=eingtech");

SqlDataAdapter adp = new SqlDataAdapter("select * from users", Cn);

DataTable dt = new DataTable();

adp.Fill(dt);

StreamWriter sw = new StreamWriter("c:\\csvData.csv", false);

int iColCount = dt.Columns.Count;

for (int i = 0; i < iColCount; i++)

{

sw.Write(dt.Columns[i]);

if (i < iColCount - 1)

{

sw.Write(",");

}

}

sw.Write(sw.NewLine);

// Now write all the rows.

foreach (DataRow dr in dt.Rows)

{

for (int i = 0; i < iColCount; i++)

{

if (!Convert.IsDBNull(dr[i]))

{

sw.Write(dr[i].ToString());

}

if (i < iColCount - 1)

{

sw.Write(",");

}

}

sw.Write(sw.NewLine);

}

sw.Close();

#endregion

}

}

}

Related Links

http://dotnetguts.blogspot.com/2007/01/exporting-datatable-to-csv-file-format.html