ScriptManager.RegisterStartupScript(this, GetType(), "a_key", "<script type='text/javascript' src='test.js'></script> <script type='text/javascript'>kk();</script> ",
Friday, 30 May 2014
Monday, 26 May 2014
Upload File Validate Type and Size in .net
<script type="text/javascript">
function checkfilesize(source, arg) {
var flag1 = true;
tt = "";
var totalsize = 0;
if (document.getElementById('<%= FileUploadidfcfile.ClientID %>').value != "" && flag1 == true) {
var fSize = (document.getElementById('<%= FileUploadidfcfile.ClientID %>').files[0].size / 1024);
totalsize = parseInt(fSize);
var actualSize = fSize;
fSize = (Math.round((fSize / 1024) * 100) / 100)
if (parseInt(fSize) > 10) {
arg.IsValid = false;
} else
{
arg.IsValid = true;
}
}
}
</script>
<asp:FileUpload ID="FileUploadidfcfile" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="FileUploadidfcfile"
Display="Dynamic" runat="server" ErrorMessage="please select file" ForeColor="Red"
ValidationGroup="submit"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="NewPasswordCustomValidator" runat="server" Display="Dynamic"
ErrorMessage="Max file size 10mb" ForeColor="Red" ControlToValidate="FileUploadidfcfile" ClientValidationFunction="checkfilesize"
OnServerValidate="extentionvalidation_ServerValidate" ValidationGroup="submit"
EnableClientScript="true"></asp:CustomValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidatorfile2" CssClass="errorMsg"
runat="server" ErrorMessage="Please select correct file(pdf,sip,xls,xlsx)" ForeColor="Red" ValidationExpression="^.*\.(XLS|xls|XLSX|xlsx|pdf|PDF|ZIP|zip)$"
ControlToValidate="FileUploadidfcfile" ValidationGroup="submit" Display="Dynamic"> </asp:RegularExpressionValidator>
protected void extentionvalidation_ServerValidate(object sender, ServerValidateEventArgs args)
{
args.IsValid = false;
if (FileUploadidfcfile.FileBytes.Length > 10491876)
{
args.IsValid = false;
}
}
function checkfilesize(source, arg) {
var flag1 = true;
tt = "";
var totalsize = 0;
if (document.getElementById('<%= FileUploadidfcfile.ClientID %>').value != "" && flag1 == true) {
var fSize = (document.getElementById('<%= FileUploadidfcfile.ClientID %>').files[0].size / 1024);
totalsize = parseInt(fSize);
var actualSize = fSize;
fSize = (Math.round((fSize / 1024) * 100) / 100)
if (parseInt(fSize) > 10) {
arg.IsValid = false;
} else
{
arg.IsValid = true;
}
}
}
</script>
<asp:FileUpload ID="FileUploadidfcfile" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="FileUploadidfcfile"
Display="Dynamic" runat="server" ErrorMessage="please select file" ForeColor="Red"
ValidationGroup="submit"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="NewPasswordCustomValidator" runat="server" Display="Dynamic"
ErrorMessage="Max file size 10mb" ForeColor="Red" ControlToValidate="FileUploadidfcfile" ClientValidationFunction="checkfilesize"
OnServerValidate="extentionvalidation_ServerValidate" ValidationGroup="submit"
EnableClientScript="true"></asp:CustomValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidatorfile2" CssClass="errorMsg"
runat="server" ErrorMessage="Please select correct file(pdf,sip,xls,xlsx)" ForeColor="Red" ValidationExpression="^.*\.(XLS|xls|XLSX|xlsx|pdf|PDF|ZIP|zip)$"
ControlToValidate="FileUploadidfcfile" ValidationGroup="submit" Display="Dynamic"> </asp:RegularExpressionValidator>
protected void extentionvalidation_ServerValidate(object sender, ServerValidateEventArgs args)
{
args.IsValid = false;
if (FileUploadidfcfile.FileBytes.Length > 10491876)
{
args.IsValid = false;
}
}
Thursday, 22 May 2014
Find Control UserControl to UserControl , Find Control of Master page, Find html Control of Master page,Find Control in parent page
UserControl objOfUserControl = (UserControl)Page.FindControl("UserControlID");
TextBox txtLocation = objOfUserControl.FindControl("txtLocation") as TextBox;
txtLocation.Enabled = false;
ContentPlaceHolder MainContent = Page.Master.FindControl("ContentPlaceHolder2") as ContentPlaceHolder;
HtmlGenericControl divviewgride = (HtmlGenericControl)MainContent.FindControl("divviewgride") as HtmlGenericControl;
divviewgride.Visible = true;
ContentPlaceHolder MainContent = Page.Master.FindControl("ContentPlaceHolder2") as ContentPlaceHolder;
LinkButton ResultsLabel = MainContent.FindControl("lnkTags") as LinkButton;
ResultsLabel.Visible = false;
SubString in sql for File Extension
SELECT RIGHT('myFile3333333333333333.txt',
CHARINDEX('.', REVERSE('myFile.txt'))-1) AS 'File Extension'
case lower(RIGHT(dc.UploadFile,
CHARINDEX('.', REVERSE('.zip'))-1)) when 'xls' then 'ver11xls_icon' when 'zip' then 'ver11zip_icon' else 'none' end
CHARINDEX('.', REVERSE('myFile.txt'))-1) AS 'File Extension'
case lower(RIGHT(dc.UploadFile,
CHARINDEX('.', REVERSE('.zip'))-1)) when 'xls' then 'ver11xls_icon' when 'zip' then 'ver11zip_icon' else 'none' end
Subscribe to:
Comments (Atom)