aspx Tutorial

NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here

Toolbar

Get our toolbar!

Advertize



{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, November 11, 2010
Binding Generic List to DropDownList server control in asp.net More
{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, November 11, 2010
How to find Maximum & Minimum number from a Generic List using Linq to SQL. More
{#advanced_dlg.about_title}
by Aamir Hasan   on Wednesday, November 10, 2010
how to pass value from code behind to javascript. More
{#advanced_dlg.about_title}
by Aamir Hasan   on Wednesday, November 10, 2010
how to pass javascript value to server side. More
{#advanced_dlg.about_title}
by Aamir Hasan   on Monday, November 8, 2010
how to get file extension without file name in asp.net. More
{#advanced_dlg.about_title}
by Aamir Hasan   on Sunday, November 7, 2010
A simple toggle event method on div layer using jQuery More
{#advanced_dlg.about_title}
by Aamir Hasan   on Sunday, November 7, 2010
CSS grandient effect on div background. More
{#advanced_dlg.about_title}
by Aamir Hasan   on Friday, November 5, 2010
In this example, i have told you how to download file from FTP using C#/VB.NET.Let's start Namespaces required: C# using System.Net;using System.IO; VB.NET Imports System.NetImports System.IO Following is the code of download file from the FTP Server. C# private void Download(string filePath, string fileName)    {        FTPSettings.IP = "DOMAIN NAME";        FTPSettings.UserID = "USER ID";        FTPSettings.Password = "PASSWORD";        FtpWebRequest reqFTP = null;        Stream ftpStream = null;        try        {            FileStream outputStream = new FileStream(filePath + "\\" + fileName, FileMode.Create);            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + FTPSettings.IP + "/" + fileName));            reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;            reqFTP.UseBinary = true;            reqFTP.Credentials = new NetworkCredential(FTPSettings.UserID, FTPSettings.Password);            FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();            ftpStream = response.GetResponseStream();            long cl = response.ContentLength;            int bufferSize = 2048;            int readCount;            byte[] buffer = new byte[bufferSize];            readCount = ftpStream.Read(buffer, 0, bufferSize);            while (readCount > 0)            {                outputStream.Write(buffer, 0, readCount);                readCount = ftpStream.Read(buffer, 0, bufferSize);            }            ftpStream.Close();            outputStream.Close();            response.Close();        }        catch (Exception ex)        {            if (ftpStream != null)            {                ftpStream.Close();                ftpStream.Dispose();            }            throw new Exception(ex.Message.ToString());        }    }    public static class FTPSettings    {        public static string IP { get; set; }        public static string UserID { get; set; }        public static string Password { get; set; }    } VB.NET    Private Sub Download(ByVal filePath As String, ByVal fileName As String)        FTPSettings.IP = "DOMAIN NAME"        FTPSettings.UserID = "USER ID"        FTPSettings.Password = "PASSWORD"        Dim reqFTP As FtpWebRequest = Nothing        Dim ftpStream As Stream = Nothing        Try            Dim outputStream As New FileStream(filePath + "\" + fileName, FileMode.Create)            reqFTP = DirectCast(FtpWebRequest.Create(New Uri("ftp://" + FTPSettings.IP + "/" + fileName)), FtpWebRequest)            reqFTP.Method = WebRequestMethods.Ftp.DownloadFile            reqFTP.UseBinary = True            reqFTP.Credentials = New NetworkCredential(FTPSettings.UserID, FTPSettings.Password)            Dim response As FtpWebResponse = DirectCast(reqFTP.GetResponse(), FtpWebResponse)            ftpStream = response.GetResponseStream()            Dim cl As Long = response.ContentLength            Dim bufferSize As Integer = 2048            Dim readCount As Integer            Dim buffer As Byte() = New Byte(bufferSize - 1) {}            readCount = ftpStream.Read(buffer, 0, bufferSize)            While readCount > 0                outputStream.Write(buffer, 0, readCount)                readCount = ftpStream.Read(buffer, 0, bufferSize)            End While            ftpStream.Close()            outputStream.Close()            response.Close()        Catch ex As Exception            If ftpStream IsNot Nothing Then                ftpStream.Close()                ftpStream.Dispose()            End If            Throw New Exception(ex.Message.ToString())        End Try    End Sub    Public NotInheritable Class FTPSettings        Private Sub New()        End Sub        Public Shared Property IP() As String            Get                Return m_IP            End Get            Set(ByVal value As String)                m_IP = Value            End Set        End Property        Private Shared m_IP As String        Public Shared Property UserID() As String            Get                Return m_UserID            End Get            Set(ByVal value As String)                m_UserID = Value            End Set        End Property        Private Shared m_UserID As String        Public Shared Property Password() As String            Get                Return m_Password            End Get            Set(ByVal value As String)                m_Password = Value            End Set        End Property        Private Shared m_Password As String    End Class Download DownloadFile.zip (1.24 kb) You can use Download function in both asp.net and Windows Form csharp/VB.Net Application.
{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, November 4, 2010
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 There are lots of factor’s you have to see when you are going to design a website. Website should be human readable and interact the site so user will spend more time on your website. Style is also one big factor of your web site to interact the users. Website should be human readable. In this example I have create a simple form style, when you focus on input text box, jQuery focus event will add CSS class on focus textbox. Here’s an example <html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server">    <title>Change style effect on Input form using jQuery</title>    <style type="text/css">        html,body,table        {            font-family: Verdana;            font-size: 12px;        }        h2        {            font-size: 1.5em;            line-height: 1em;        }        input        {            background-color: #f9f9f9;            border: 1px solid #eee;            color: #999;        }        .add-focus        {            border: 1px solid #eaeaea;            background-color: White;            color: #666;        }    </style>    <script src="http://code.jquery.com/jquery-1.4.3.min.js" type="text/javascript"></script>    <script language="javascript">        $(document).ready(function () {            $('input[type="text"]').focus(function () {                $(this).addClass("add-focus");            });            $('input[type="text"]').blur(function () {                $(this).removeClass("add-focus");            });        });       </script></head><body>    <form id="form1" runat="server">    <div>        <h2>            Change style effect on Input form using jQuery        </h2>        <p>            <table width="500" border="0" cellspacing="0" cellpadding="0">                <tr>                    <th width="150" height="25" align="left" valign="top" scope="col">                        Username:                    </th>                    <th width="350" height="25" align="left" valign="top" scope="col">                        <asp:TextBox ID="tbUsername" runat="server" />                    </th>                </tr>                <tr>                    <th height="25" align="left" valign="top" scope="col">                        Email:                    </th>                    <th height="25" align="left" valign="top" scope="col">                        <asp:TextBox ID="tbEmail" runat="server" />                    </th>                </tr>                <tr>                    <th height="25" align="left" valign="top" scope="col">                        Password:                    </th>                    <th height="25" align="left" valign="top" scope="col">                        <asp:TextBox ID="tbpassword" runat="server" TextMode="Password" />                    </th>                </tr>                <tr>                    <th height="25" align="left" valign="top" scope="col">                        Retype password:                    </th>                    <th height="25" align="left" valign="top" scope="col">                        <asp:TextBox ID="tbRpassword" runat="server" TextMode="Password" />                    </th>                </tr>                <tr>                    <th height="25" align="left" valign="top" scope="col">                        &nbsp;                    </th>                    <th height="25" align="left" valign="top" scope="col">                        <input id="btSubmit" type="button" value="Submit" />                    </th>                </tr>            </table>        </p>    </div>    </form></body></html> Output Download FormStyle.zip (1.21 kb) Live demo
{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, November 4, 2010
Yesterday, some one asked me how to remove whitespaces at beginging and end of a string in javascript. So, i decided to make a trim function which will remove whitespaces from begining and end of a string. Here's an example <!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></title>    <script language="javascript">        function LTrim(value) {            var re = /\s*((\S+\s*)*)/;            return value.replace(re, "$1");        }        function RTrim(value) {            var re = /((\s*\S+)*)\s*/;            return value.replace(re, "$1");        }        function trim(value) {            return LTrim(RTrim(value));        }        function getValue() {            var username = trim(document.getElementById('<%=TextBox1.ClientID %>').value);            if (username != '')                alert(username);        }          </script></head><body>    <form id="form1" runat="server">    <div>        Username:        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>        <input id="Button2" type="button" value="Submit" onclick="return getValue();" />    </div>    </form></body></html> Output Download Trim function.zip (894.00 bytes) Live demo
Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5