File Uploading tips in ASP.NET

Error: Access denied

It is very common experience to every developer when he/she host a file uploader page.  Interestingly developer does not face this error in development PC.

The main reason of this problem is security issue of the host computer. Host pc does not allow write operation of IU or Guest user. But IU and guest user need write access of upload folder in host pc.

the solution if not very standard considering security. follow the below steps,

1.  enable write access of virtual directory of the page using IIS(default value of write access is unchecked )

2. Right write click uploading folder of the site. In the security tab provide write access to Users, Internet Guest Account.


3. Complete

The main disadvantage of this technique is the security. Write access of IU user some time vulnerable. so, alternatively your can use database to store file instead of file system.

GIS Programmer, CEGIS

Some important technique in JavaScript

##Some simple JavaScript Technique

##Open Popup with sending a URl get value:

function ItemDetails(pName,id)
{ alert(id); + "?ID=" + id,"MyWindow","status = 1,height = 400,width = 550,resizable = 1,toolbar=1'")

//Open JS Popup from code behind

string str="";
str = str + "'PrintMap.aspx?id=" + id + "','PrintMe','height=520px,width=620px,scrollbars=1,resizable=yes,toolbar=yes')";

str = str + "";
ClientScript.RegisterStartupScript(this.GetType(), "onclick", str);

// below technique is not recommended

string tem;
tem = "Page2.aspx";
Response.Write("script'" + tem + "','_blank','scrollbars=yes,width=400,height=500,resizable=yes') script");

##Page redirection using JS:

//redirect to current page(Not reload)

##Close Popup and reflect chage to parrent page

function closePopup()
/* OR window.opener.document.location.href='myParentWindow.newpage'; */
//self.close ()

##Check is not number value in javascript

function CheckAge(source, arguments)
{ var myVal=arguments.Value;
if(isNaN(myVal) || myVal<19)

Use Checkbox in Grid templetefield

we can esily use checkbox into templetefiled in grid control. If you use Mysql, it is better to use field data type as bit. Again you can also use text type where you store value like YES/NO.

Now, please go to the page source view. Add a new template field in the grid like below,

Here check box is not two way binding. you can not use Bind. so you need some care in the time inserting. Write below code in grid view RowUpdating event,

// in grid row updating event
e.NewValues["isZoomToExtent"]= ((CheckBox)GridView1.Rows[GridView1.EditIndex].FindControl("editChkIsZoomToExtent")).Checked;

All is done, you can now enjoy the output

GIS Programmer, CEGIS