I am adding a check to verify the size of the file imported in my web application. If the file size is greater than 4 MB i need to show a confirmation pop, whether a user is sure to upload the file. If user selects yes the default functionality occurs else upload is cancelled.
I am trying to open a confirmation pop up from server side using
Page.ClientScript.RegisterStartupScript(typeof(NewDocument), "ValidateFileSize", "<script>ValidateFileSize()</script>");
Where ValidateFileSize()
is a JavaScript function that shows the confirmation box.
But the problem is, the control of the page at server side moves ahead before I set the result of the confirmation pop up using hidden variable and use it in 'if-else
' condition. Therefore, i am unable to read the value of the hidden variable and skipping the uploading code at server side.
I am using the concept of hidden variable as in javascript element.files.size
does not work in IE8.
Could anyone suggest a better approach or solution to this. Or the only solution is using .aspx page as a popup?