<%@ Page Language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <script language="javascript" type="text/javascript"> function checkIt(obj, evt) { evt = (evt) ? evt : window.event var charCode = (evt.which) ? evt.which : evt.keyCode if ((charCode < 45 || charCode > 57) && charCode != 8 && charCode != 37 && charCode != 39) { alert("This field accepts numbers only") return false } var t = (charCode / 1) - 48; var v = obj.value + t; var value = v / 1; if(value > 24){ alert("Number should be less than 24"); return false; } return true } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox runat="server" ID="txtNumber" onKeyPress='javascript:return checkIt(this, event)' /> </div> </form> </body> </html>
Saturday, December 17, 2011
How to validate a number between 0-24 with Java Scripts
Wednesday, December 14, 2011
How to retain the password in a postback
<%@ Page Language="C#" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test Page</title> <script runat="server"> public string Password { get { return ViewState["Password"] as string; } set { this.ViewState["Password"] = value; } } protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (this.IsPostBack) { if (!string.IsNullOrEmpty(this.txtPassword.Text)) this.Password = this.txtPassword.Text; this.txtPassword.Attributes.Add("value", this.Password ?? string.Empty); } } </script> </head> <body> <form id="aspNetForm" runat="server"> UserName: <asp:TextBox runat="server" ID="txtName" /> Password: <asp:TextBox runat="server" ID="txtPassword" TextMode="Password" /> <hr /> <asp:Button runat="server" ID="btnSave" Text="Save" /> </form> </body> </html>
Tuesday, December 13, 2011
Html Header Tag Sizes
- H1 - 24pt / 32px
- H2 - 18pt / 24px
- H3 - 14pt / 18px
- H4 - 12pt / 15px
- H5 - 10pt / 13px
- H6 - 8pt / 11px
Friday, August 19, 2011
How to upload a external image link url and save on the disk
We can get the use of HttpWebRequest and HttpWebResponse to send the request and get the response. Then response.GetResponseStream() will give us a stream of the image where we can use that stream to create a Image object like Image image = Image.FromStream(stream)
Markup:
Markup:
<%@ Page Language="C#" CodeBehind="Test.aspx.cs" Inherits="ActiveTest.Test" %> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox runat="server" ID="txtUpload" Text="http://www.web-sphere.co.uk/web/websphere/blog/bloggerheader.jpg" /> <asp:Button runat="server" ID="btnUpload" OnClick="Upload" Text="Upload" /> </div> </form> </body> </html>Code:
namespace ActiveTest { public partial class Test : Page { protected void Upload(object sender, EventArgs e) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.txtUpload.Text); HttpWebResponse response = request.GetResponse() as HttpWebResponse; Stream stream = response.GetResponseStream(); /// /// use response content type to findout the image type, /// here I just use jpg to simplify the story. /// System.Drawing.Image image = System.Drawing.Image.FromStream(stream); image.Save(this.Server.MapPath(string.Format("~/Uploads/{0}.jpg",Guid.NewGuid()))); } } }
Subscribe to:
Posts (Atom)
Azure Storage Account Types
Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...
-
Why we need asynchronous tasks? Execute a time consuming operations in parallel to the CLR thread which execute the request If you have ...
-
Demo: I was thinking a way to show images before actually uploading them to server. I would say to preview images using javascript. Obv...