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 4, 2010
In this example, i have told you how to Rename file name on FTP server. FTP (File Transfer protocol) is used to transfer a file on another server. To Rename File name on FTP server you must have IP Address, username and password to connect to FTP server.Let's start. Namespace required to work FtpWebRequest and Stream Class. C#using System.Net;using System.IO;VB.NETImports System.NetImports System.IO Rename Filename on FTP Server function C#    private void RenameFileName(string currentFilename, string newFilename)    {        FTPSettings.IP = "DOMAIN NAME";        FTPSettings.UserID = "USER ID";        FTPSettings.Password = "PASSWORD";        FtpWebRequest reqFTP = null;        Stream ftpStream = null ;        try        {            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + FTPSettings.IP + "/" + currentFilename));            reqFTP.Method = WebRequestMethods.Ftp.Rename;            reqFTP.RenameTo = newFilename;            reqFTP.UseBinary = true;            reqFTP.Credentials = new NetworkCredential(FTPSettings.UserID, FTPSettings.Password);            FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();            ftpStream = response.GetResponseStream();            ftpStream.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 RenameFileName(ByVal currentFilename As String, ByVal newFilename As String)        FTPSettings.IP = "DOMAIN NAME"        FTPSettings.UserID = "USER ID"        FTPSettings.Password = "PASSWORD"        Dim reqFTP As FtpWebRequest = Nothing        Dim ftpStream As Stream = Nothing        Try            reqFTP = DirectCast(FtpWebRequest.Create(New Uri("ftp://" + FTPSettings.IP + "/" + currentFilename)), FtpWebRequest)            reqFTP.Method = WebRequestMethods.Ftp.Rename            reqFTP.RenameTo = newFilename            reqFTP.UseBinary = True            reqFTP.Credentials = New NetworkCredential(FTPSettings.UserID, FTPSettings.Password)            Dim response As FtpWebResponse = DirectCast(reqFTP.GetResponse(), FtpWebResponse)            ftpStream = response.GetResponseStream()            ftpStream.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   Function to used as C# RenameFileName("file1.txt","file2.text"); VB.NET RenameFileName("file1.txt","file2.text") You can use this function on both website and desktop Application Download FTP Rename FileName.zip.zip (1.10 kb)
Tags:
{#advanced_dlg.about_title}
by Aamir Hasan   on Wednesday, November 3, 2010
In this example, I have demonstrate, how to Split a string using Linq query... More
{#advanced_dlg.about_title}
by Aamir Hasan   on Wednesday, November 3, 2010
In this example, I have demonstrate, how to match a string from a string Array... More
Tags:
{#advanced_dlg.about_title}
by Aamir Hasan   on Wednesday, November 3, 2010
how to get all Files list from a specific directory using Linq query... More
{#advanced_dlg.about_title}
by Aamir Hasan   on Tuesday, November 2, 2010
how to detect mouse x and y axis on the page... More
{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, October 7, 2010
You can easily find some javascript code over the internet to disable right click on your page. but jQuery make it so simple by using oneline of code.jQuery library provids a bind method bind() Attaching behavior to a document is called bind(). I have bind contextmenu event to document. Syntax .bind( eventType, [ eventData ], handler(eventObject) ) Why we disable right click Most of people wants to disable right click in their site because of "Save as images" but there are other options to save image. Before going to display HTML and images, it is download on own machine, its mean you can easily take images from your machine. To protect links to open in new tab. But, there are other options. Add following code under the HEAD tag of your aspx page Normal 0 false false false EN-US X-NONE X-NONE <head><script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>     <script type="text/javascript" language="javascript">         $(document).ready(function () {             $(document).bind("contextmenu", function (e) {                 return false;             });         });     </script> </head> Click here to see demo and source code
{#advanced_dlg.about_title}
by Aamir Hasan   on Sunday, September 26, 2010
I was surprise to see my article on the first page of asp.net.
{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, September 16, 2010
There are few JQuery Plugin’s on the internet, one on them is column/row hover jQuery Plug-in.I am going to demonstrate how to use column hover Plug-in with ASP.NET to display student information by fetching JSON data from server side to client side.When you take your mouse over the table column, column will be highlighted. This example uses the JQuery library. I have made this example in Visual studio 2010.when you create a web project in Visual Studio 2010, jQuery include in web project. If you don’t have Visual Studio 2010 then you can download JQuery latest version from here. Let start's. Open you Visual Studio 2010. Create a new Web Application. Open you Default.aspx Page. Add the following code given below. [WebMethod] public static List fetchStudentRecords() { List AddRecords = new List(); AddRecords.Add(new Student { RollNumber = 1, FullName = "Aamir Hasan", Class = "Five", Marks = 94, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 2, FullName = "Scott Hanselman ", Class = "Four", Marks = 93, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 3, FullName = "Saba Khan", Class = "Three", Marks = 82, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 4, FullName = "Nadia yasir", Class = "Nine", Marks = 80, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 5, FullName = "Mahwish Hasan", Class = "Two", Marks = 79, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 6, FullName = "Aamir Hassan", Class = "One", Marks = 99, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 7, FullName = "Karoly Domonyi", Class = "Five", Marks = 69, Gender = "Male" }); AddRecords.Add(new Student { RollNumber = 8, FullName = "Sana Ahmed", Class = "Five", Marks = 93, Gender = "Female" }); AddRecords.Add(new Student { RollNumber = 9, FullName = "Awais Ahmed", Class = "Ten", Marks = 91, Gender = "Male" }); return AddRecords; } } public class Student { public int RollNumber { get; set; } public String FullName { get; set; } public int Marks { get; set; } public string Class { get; set; } public string Gender { get; set; } } Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Note: Add System.Web.Services at the top of page to work web Method   Open your Default.aspx Page add css reference under head tag, for table style. Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 <link href="Styles/Style.css" rel="stylesheet" type="text/css" />   Add jQuery and table hover reference under head tag. Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script> <script src="Scripts/jquery.tablehover.js" type="text/javascript"></script>   Add the following code to retrieve JSON object using $.ajax method. Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 <script type="text/javascript">         $(document).ready(function () {             $.ajax({                 type: "POST",                 url: "Default.aspx/fetchStudentRecords",                 data: "{}",                 contentType: "application/json; charset=utf-8",                 dataType: "json",                 success: function (data) {                       $("#records").html(GenerateTable(data.d));                     $('#table1').tableHover({ colClass: 'hover' });                 }             });             function GenerateTable(data) {                 var totalRows = data.length;                 var Table = "<table id='table1'>";                 Table += "<thead><tr><th>Roll No.</th><th>Full Name</th><th>Marks</th><th>Class</th><th>Gender</th></tr></thead><tbody>";                 for (index = 0; index < totalRows; index++) {                     Table += "<tr ><td>" + data[index].RollNumber + "</td><td >" + data[index].FullName + "</td><td>" + data[index].Marks + "</td><td>" + data[index].Class + "</td><td>" + data[index].Gender + "</td></tr>";                 }                 Table += "</tbody></table>";                 return Table;               }           });     </script>   Above you see, on page load, returning Date objects in the form of JSON Serialized List<Student>. Table is generated when JSON data is returned. Add following code under the body section. <h2>Table Hover jQuery plugin with asp.net using csharp</h2> <div id="records">&nbsp;</div> Press Cltr+F5 to save and run your web application. Below you can see output you can download entire source code from here. Click here to see online demo.
{#advanced_dlg.about_title}
by Aamir Hasan   on Tuesday, September 14, 2010
Yesterday, I got the error message “operation is not valid due to the current state of the object“ when I was adding web reference in my project. So, I decided to share with you. There are several reasons Is your web service running? Something wrong in your URL You have also put web service assembly into your server Global Assembly Cache. Restart your IIS If you have more solution, post here to share with us.
{#advanced_dlg.about_title}
by Aamir Hasan   on Thursday, August 19, 2010
In this tutorial, I will show you how to transmit JSON Object. I will also use the jTemplate with jQuery within ASP.NETMVC.... More
Tags:
Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5