Faraz Shah Khan
MCP, MCAD.Net, MCSD.Net, MCTS-Win, MCTS-Web, MCPD-Web
-
Javascript Enable/Disable Dropdown in Gridview using Checkboxes
If you come up with some requirement in which you have a Checkbox and a DropDownList in GridView control and you are requried to enable disable the DropDownList on the basis of the CheckBox value you can use following Code.
-
Reading file content from different webserver using HttpWebRequest
I was replying to one of the post on the ASP.Net forum in which the requirement was like reading txt file contents from different webservers. When he got satisfied with the solution then I thought to put the piece of code in my blog as well for others and my future reference.
-
Passing value from popup window to parent form's TextBox
Once again seen lot of questions on the forum related to passing values from popup window to the parent form textbox. Specially when they have some GridView type control in the popup. In the following example I will be using two forms, parent form will be parent.aspx and popup will be popup.aspx. Also note that my parent.aspx form is derived from some MasterPage. Code is provided both in VB.Net and C#.Net.
-
Javascript to display time on Web page
Javascript to display continuous time on the Web page. By continuous it means that it will be displayed second by second.
-
Check/Uncheck checkboxes in GridView using javascript
----------------------------------------- .cs file if C#.Net is the language ------------------------------------------
C#.Net Code -
Personalization Scope
<authorization>
<allow verbs="enterSharedScope" users="*" />
</authorization>
.
. -
Uploading File using FtpWebRequest
For those people who are interested to use FtpWebRequest to upload files on a server. Here is the code:FtpWebRequest ftpRequest;
FtpWebResponse ftpResponse;
try
{
//Settings required to establish a connection with the server
this.ftpRequest = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://ServerIP/FileName"));
this.ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
this.ftpRequest.Proxy = null;
this.ftpRequest.UseBinary = true;
this.ftpRequest.Credentials = new NetworkCredential("UserName", "Password");
//Selection of file to be uploaded
FileInfo ff = new FileInfo("File Local Path With File Name");//e.g.: c:\\Test.txt
byte[] fileContents = new byte[ff.Length];
using (FileStream fr = ff.OpenRead()) //will destroy the object immediately after being used
{
fr.Read(fileContents, 0, Convert.ToInt32(ff.Length));
}
using (Stream writer = ftpRequest.GetRequestStream())
{
writer.Write(fileContents, 0, fileContents.Length);
}
this.ftpResponse = (FtpWebResponse)this.ftpRequest.GetResponse(); //Gets the FtpWebResponse of the uploading operation
Response.Write(this.ftpResponse.StatusDescription); //Display response
}
catch (WebException webex)
{
this.Message = webex.ToString();
} -
Javascript to open application on client's machine
Long time back I was wondering if some how I will be able to open any application through my website on client's machine. Finally I came to know that yes it is possible and I will end up with this code.