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;
       
        }
    }

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



Monday, 28 April 2014

Validation for enter key and double quot



Validation for enter key and double quot;

FilteredTextBoxExtender3.ValidChars = FilteredTextBoxExtender3.ValidChars + "\r\n";

<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server"
                                FilterType="Custom, Numbers, UppercaseLetters, LowercaseLetters" ValidChars=" !@#$%&(),./= +&quot;"  TargetControlID="txtMessage"> </cc1:FilteredTextBoxExtender>

Friday, 11 April 2014

Multiple element drag and drop

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

  <meta charset="utf-8">
  <title>jQuery UI Sortable - Connect lists</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <style>
  #sortable1, #sortable2 , #sortable3{ list-style-type: none; margin: 0; padding: 0 0 2.5em; float: left; margin-right: 10px; }
  #sortable1 li, #sortable2 li , #sortable3 li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; }
  </style>
  <script>
      $(function () {
          $("#sortable1, #sortable2 , #sortable3").sortable({
              connectWith: ".connectedSortable"
          }).disableSelection();
      });
  </script>
</head>



<body>

<ul id="sortable1" class="connectedSortable">
  <li class="ui-state-default">Item 1</li>
  <li class="ui-state-default">Item 2</li>
  <li class="ui-state-default">Item 3</li>
  <li class="ui-state-default">Item 4</li>
  <li class="ui-state-default">Item 5</li>
</ul>

<ul id="sortable2" class="connectedSortable">
  <li class="ui-state-highlight">Item 1</li>
  <li class="ui-state-highlight">Item 2</li>
  <li class="ui-state-highlight">Item 3</li>
  <li class="ui-state-highlight">Item 4</li>
  <li class="ui-state-highlight">Item 5</li>
</ul>

 <ul id="sortable3" class="connectedSortable">
  <li class="ui-state-highlight">Item 1</li>
  <li class="ui-state-highlight">Item 2</li>
  <li class="ui-state-highlight">Item 3</li>
  <li class="ui-state-highlight">Item 4</li>
  <li class="ui-state-highlight">Item 5</li>
</ul>

</body>
</html>

Thursday, 10 April 2014

Date sorting in xsl

 <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/><br/>
    </xsl:copy>
  </xsl:template>



  <xsl:template match="INSTestElements">
    <xsl:copy>
   
      <xsl:apply-templates select="INSTestElement">
        <xsl:sort select="substring(substring-after(substring-after(Created, '/'), '/'), 1, 4)" data-type="number" order="descending"/>
        <xsl:sort select="substring(Created, 1, 2)" data-type="number" order="descending"/>
        <xsl:sort select="substring-before(substring-after(Created, '/'), '/')" data-type="number" order="descending"/>
   
      </xsl:apply-templates>
     
    </xsl:copy>
  </xsl:template>

Monday, 7 April 2014

For each for ary in xsl and xslt

 <xsl:variable name="k" select="@id" />
      <xsl:variable name="list" select="'4 5 6'" />
   
     <xsl:if test="
  contains(
    concat(' ', $list, ' '),
    concat(' ', $k, ' ')
  )
">
      hanmant <xsl:value-of select="concat('ID- ', $k, ' is in the list.')" />
      </xsl:if>