Showing posts from 2008

How to hide generated javascript file in visual studio code

In this post I am going to show you a cool trick in visual studio code. Let's suppose you are writing typescript code in visual studio code and you want to hide generated javascript code.

Create .vscode folder in your folder and then create settings.json file and paste following code

{ "files.exclude": { "node_modules":true, "**/.git": true, "**/.DS_Store": true, "**/*": true, "**/*.js": {"when": "$(basename).ts"}     } }

Creating javascript alerts in ASP.NET with UpdatePanel

creating an alert when you are using an UpdatePanel is slightly different, but simpler than you might think - you just need to make sure the System.Type is the UpdatePanel type, and use the ScriptManager rather than the ClientScript like so <%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpdatePanel.aspx.cs" Inherits="UpdatePanel" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><asp:ScriptManagerID="scriptMangerTest"runat="Server"></asp:ScriptManager><asp:UpdatePanelID="updateTest"runat="Server"><ContentTemplate><div><tablecellpadding="0"cellsp… TreeView Tips and Trics

In this Post i will show How to Automatically check all ChildNode CheckBoxes on Checking ParentNode CheckBox using JavaScriptHow to get checked value from treeviewHow To open Treeview in ModalPopupExtender control<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headid="Head1"runat="server"><title>Untitled Page</title><styletype="text/css"> .modalBackground { background-color:Gray; filter:alpha(opacity=70); opacity:0.7; } .modalPopup { background-color:#FFD9D5; border-width:3px; border-style:solid; border-color:Gray; padding:3px; …

How to make your ASP.Net label multilin

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Multiline.aspx.cs" Inherits="Multiline"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><div><asp:LabelID="lblMultiline"runat="Server"Text=""></asp:Label></div></form></body></html>using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; publicpartialclass Multiline : System.Web.UI.Page { protectedvoid…

How To Create TextBox Control Dynamically at Runtime

Image in this post i will show how to create Textbox Control dynamically and read there value. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TextBoxDynamic.aspx.cs" Inherits="TextBoxDynamic" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><div><tablewidth="100%"cellpadding="0"cellspacing="0"><tr><tdcolspan="2"><asp:PlaceHolderID="phTextBoxes"runat="Server"></asp:PlaceHolder></td></tr><tr><td><asp:ButtonID="btnAddTitle&qu…

How To Use RegularExpressionValidator with FileUpload control

In this post i will show how to use RegularExpressionValidator to check to make sure the file is a .doc, or .txt extension.<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUploadTest.aspx.cs" Inherits="FileUploadTest" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><div><tablecellpadding="0"cellspacing="0"width="100%"><tr><td> Select File</td><td><asp:FileUploadID="fileUpload"runat="Server"/></td><td><tdalign="left"><asp:RegularExpressionValidatorrunat="server"ID=&quo…

How To Add Multiple UserControls using RequiredFieldValidators that work independently

The trick is to make the Validation Group name in each user control unique. Since its a single user control used in both places, you have to make it unique programmatically. Do this in Page_Load of the user control:Assign the value of the UniqueID property of the UserControl to each ValidationGroup property on the UserControl. Something like this:publicstring ValidationGroup { get { if (ViewState["VALGROUP"] == null) returnthis.ClientID; elsereturn (string)ViewState["VALGROUP"]; } set { ViewState["VALGROUP"] = this.ClientID; } } Create an UserControl Test.ascx <%@ Control Language="C#" AutoEventWireup="true" CodeFile="Test.ascx.cs" Inherits="Test" %><asp:TextBoxID="txt1"runat="Server"></asp:TextBox><asp:RequiredFieldValidatorID="req1"runat="Server"ErrorMessage="(Require)"Con…

How To Make Clickable image

The Image Web server control is used to display an image on a Web page. To set the image to be displayed for this control we use the ImageUrl property.In this post i will show how to make Clickable image .(Unfortunately image control not supports NavigateUrl ) <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN"""><htmlxmlns=""><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"/><div><aid="link1"runat="Server"><asp:ImageID="SlideShowImage1"CssClass="crop"runat="server"Width="630px"…

SQL XML output to populate a treeview

In this post I will show howto populate an tree view from the output of sql stored procedure. The table looks like this:pageid pagename parentid--- ---------- -------------1 N1 03 N4 14 N10 35 N7 3SET ANSI_NULLS ONSET QUOTED_IDENTIFIER ONGOALTERPROCEDURE [DBO].[gentree] ASBEGINSET NOCOUNT ON; WITH TREE AS (SELECTCAST(1 ASINT) ASLEVEL, PAGEID, PAGENAME, CAST(RIGHT(' ' + CONVERT(VARCHAR(11),PAGEID),11) ASVARCHAR(120)) AS HIERARCHY FROM PAGE WHERE PARENTID = '0'UNIONALLSELECTLEVEL + 1, B.PAGEID, B.PAGENAME, CAST(A.HIERARCHY + '/' + RIGH…

How To Add Session Timeout Popup in

If you need to alert a user that his session will time out. This is how to do it. Add the following code snippet to the OnInit method on the base page of your application. protectedoverridevoid OnInit(EventArgs e) { base.OnInit(e); string script = "window.setTimeout(\"alert('Your session expired!');\", " + (Session.Timeout - 1) * 60000 + ")"; this.Page.ClientScript.RegisterStartupScript(this.GetType(), "SessionManager", "<script language=\"javascript\">" + script + "</script>"); }

AdRotator control and Database

The AdRotator control reads advertisement information from a data source, which contains one or more ad records. You can store ad information in a database table with a specific schema, and then use a data source control to read the ad records at run time. If you have an existing table with ad information, you can map the schema of your table to the fields that are required by the AdRotator control. You can store ad information in any type of database, as long as you have the corresponding data source control for that database. To create the database table for ads1. If you do not already have a database table that contains the ad information, create a table with the following schema. All columns except ID are optional. Data types are provided as SQL Server types. If you are using a different database, substitute the appropriate corresponding type. Column name Data type Description ID int Primary key. This column can have any name. ImageUrl nvarchar(length) The relative or absolute…

How To Create Slideshow using UpdatePanel and Timer

In this Post i will show how to create Slideshow using UpdatePanel and Timer Control <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN"""><htmlxmlns=""><headrunat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"/><div><asp:Timerrunat="server"Interval="10000"ID="SlideShowTimer"OnTick="SlideShowTimer_Tick"/><br/><h2style="text-transform: uppercase; margin: 10px 0px 0px 8px; disp…