File Download Dialogbox With File Extention

Write below code on download button click event…. protected void btnDownload_Click(object sender, EventArgs e) { string imgPath = btnDownload.CommandArgument; // image path goes here…(virtual path) System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath(imgPath)); if (file.Exists) { HttpContext.Current.Response.AddHeader(“Content-Disposition”, “attachment; filename=drawing”); HttpContext.Current.Response.AddHeader(“Content-Length”, file.Length.ToString()); string strExtention = file.Extension.ToString(); //HttpContext.Current.Response.ContentType = “application/octet-stream”; HttpContext.Current.Response.ContentType = strExtention; HttpContext.Current.Response.WriteFile(file.FullName); HttpContext.Current.Response.End(); } else { lblError.Text = …

Upload images in FCKEDITOR in asp.net

1) Create a folder in root namely ” userfiles ” and inside it create sub folder ” image “. So its like this userfiles \ image 2) Now edit the following lines in fckeditor\fckconfig.js file var _FileBrowserLanguage = ‘php’ ; // asp | aspx | cfm | lasso | perl | php | py var …

Open Aspx Page in Popup

Add this function in Search Page or View All items page.. function ShowPopUp(Id) { $get(”).src=”AssignTool.aspx?ID=”+Id; $find(”).show(); document.getElementById(“”).innerHTML = “Assign Tool”; return false; } —————– View All Items page ———–   ——————— view All cs page coding ————— Gridview Row DataBound Event if (e.Row.RowType == DataControlRowType.DataRow) { Button btnAccept = (Button)e.Row.Cells[16].Controls[0]; btnAccept.Attributes.Add(“onclick”, “return ShowPopUpAccept(” + rowView[“AssignToolId”].ToString() …

Date Comparision Javascript Validation

function ValidateDate() { var str1 = document.getElementById(“”).value; var str2 = document.getElementById(“”).value; var dt1 = parseInt(str1.substring(0,2),10); var mon1 = parseInt(str1.substring(3,5),10); var yr1 = parseInt(str1.substring(6,10),10); var dt2 = parseInt(str2.substring(0,2),10); var mon2 = parseInt(str2.substring(3,5),10); var yr2 = parseInt(str2.substring(6,10),10); var date1 = new Date(yr1, mon1, dt1); var date2 = new Date(yr2, mon2, dt2); if(date2 < date1) { alert("To date …

Find Master Page Control In Content Page

Home News If I have understood this correctly… If your list is on the master page… Home News …then you can do this on your content page… Control list = this.Page.Master.FindControl(“list”); Then the li objects will be controls in the list object – e.g. list.Controls. Or you can do… Control home = this.Page.Master.FindControl(“list”).FindControl(“home”); …to find …

Javascript Validation in Gridview

Make function in “Java Script” as Below… grvPowderCoat is Gridview ID function PowderCoatValidate() { var result=””; var GrvTst = document.getElementById(GetClientId(“grvPowderCoat”)); if (GrvTst != null) { var Inputs = GrvTst.getElementsByTagName(“input”); for (i = 0; i < Inputs.length; i++) { if (Inputs[i].type == 'text') { var test1 = Inputs[i].id; var array1 = test1.split("_"); if (array1[array1.length-1] == 'txtPowderA') …

Enalbe Or Disable Controls In Asp.Net

Give ID and runat=”server” attribute to Div or Table Tag for enable or disable the controls in it. Write the followin function and call them on any event. Disable Controls private void DisableControls(Control parent) { foreach (Control _ChildControl in parent.Controls) { if ((_ChildControl.Controls.Count > 0)) { DisableControls(_ChildControl); } else { if (_ChildControl is TextBox) { …

Display Confirmation Message on Gridview Deleting

Write Javascript into head tag……… <head runat=”server”>     <title>GridView Data Manipulation</title>     <script type=”text/javascript” language=”javascript”>         function ConfirmOnDelete(item)         {           if (confirm(“Are you sure to delete: ” + item + “?”)==true)             return true;           else             return false;         }     </script> </head> Aspx page: Gridview <Columns>     <asp:BoundField DataField=”CustomerID” HeaderText=”ID” ReadOnly=”true” /> …