ایجاد منوی داینامیک و خواندن آن از پایگاه داده

Function createMenu() As String

        Dim ds As New DataSet()

        Dim cn As New SqlConnection(DB.connectionStirng.ConnectionString())

        Dim cmd As New SqlCommand("SELECT * FROM content order by sort asc", cn)

        Dim da As New SqlDataAdapter(cmd)

        da.Fill(ds)

        Dim table As DataTable = ds.Tables(0)

        Dim parentMenus As DataRow() = table.Select("[parent]=1")

 

        Dim sb = New StringBuilder()

        Dim unorderedList As String = GenerateUL(parentMenus, table, sb)

        Return (unorderedList)

    End Function

 

    Private Function GenerateUL(ByVal menu As DataRow(), ByVal table As DataTable, ByVal sb As StringBuilder) As String

        sb.AppendLine("<ul>")

 

        If menu.Length > 0 Then

            For Each dr As DataRow In menu

                Dim menuText As String = dr("title").ToString()

                Dim line As String = [String].Format("<li><a href=#>{0}</a>", menuText)

                sb.AppendLine(line)

 

                Dim pid As String = dr("id").ToString()

 

                Dim subMenu As DataRow() = table.Select("[parent]=" & pid)

                If subMenu.Length > 0 Then

                    Dim subMenuBuilder = New StringBuilder()

                    sb.AppendLine(GenerateUL(subMenu, table, subMenuBuilder))

                End If

                sb.AppendLine("</li>")

            Next

        End If

 

        sb.Append("</ul>")

        Return sb.ToString()

    End Function

 

ارسال ایمیل با استفاده از Yahoo!, GMail, Hotmail

Server Parameters

Server NameSMTP AddressPortSSL
Yahoo!smtp.mail.yahoo.com587Yes
GMailsmtp.gmail.com587Yes
Hotmailsmtp.live.com587Yes

Sample Code

using System.Net;
using System.Net.Mail;

string smtpAddress = "smtp.mail.yahoo.com";
int portNumber = 587;
bool enableSSL = true;

string emailFrom = "email@yahoo.com";
string password = "abcdefg";
string emailTo = "someone@domain.com";
string subject = "Hello";
string body = "Hello, I'm just writing this to say Hi!";

using (MailMessage mail = new MailMessage())
mail.From = new MailAddress(emailFrom);
{
mail.To.Add(emailTo);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
// Can set to false, if you are sending pure text.

mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));

using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
{
smtp.Credentials = new NetworkCredential(emailFrom, password);
smtp.EnableSsl = enableSSL;
}
smtp.Send(mail);
}
منبع:

جستجوی صفحه به صفحه در پایگاه داده

select ID, title from software where ID IN(

   select top 10 ID from software where ID IN(

      select top 10 ID from software order by ID)

   order by id desc)

order by id

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

select top 10 * from software where id in(

    select top 10 id from software where id IN(

        select top 70 id from software order by id desc)

    order by id asc)

order by id desc

حذف جدول

DROP TABLE table_name

استفاده از طیف رنگ در CSS

#grad {
  background: -webkit-linear-gradient(red, blue); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(red, blue); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(red, blue); /* For Firefox 3.6 to 15 */
  background: linear-gradient(red, blue); /* Standard syntax */
}

منبع:

http://www.w3schools.com/css/css3_gradients.asp

گرد کردن حاشیه اشیاء در CSS

div {
    border: 2px solid;
    border-radius: 25px;
}


-webkit-border-radius: 5px;

-moz-border-radius: 5px;

border-radius: 5px;


منبع:

http://www.w3schools.com/cssref/css3_pr_border-radius.asp

ویرایش فیلد پایگاه داده برای کلید و مقدار پیش فرض

alter table [tableName]

add [fieldName] int identity(1,1)


alter table [tableName]

ADD PRIMARY KEY ([fieldName])


Expamle:

alter table attachment

add id int identity(1,1)


alter table attachment

ADD PRIMARY KEY (id)

Request Validation in ASP.NET

Disabling Request Validation in ASP.NET Web Forms (ASP.NET 4 or later)


configuration

   system.web

      httpRuntime requestValidationMode="2.0" /

      pages validateRequest="false" /

   /system.web

/configuration