Thursday, 23 November 2017

Print Footer Line in Html Page Dynamically

1.> Put below Jquery On Header Part Of Html Page With Reference Of Jquery min.
2.> Function : :
<script src="jquery.min.js"></script>
    <script type="text/javascript">
         function showViewPortSize() {           
                jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;bottom:0px;left:0px;color:#000;background:#fff;padding:10px;width:100%;"><div style="width:50%;float:left;">Prepared By :</div><div style="width:50%;float:left;">Checked By :</div></div>');           
         
            jQuery(window).resize(function () {             
                jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;bottom:0px;left:0px;color:#000;background:#fff;padding:10px;width:100%;"><div style="width:50%;float:left;">Prepared By :</div><div style="width:50%;float:left;">Checked By :</div></div>');
            });
        }
        $(document).ready(function () {
            showViewPortSize();
        }); 
        </script>

Saturday, 18 November 2017

Replace Empty String To Value Zero ("0")

declare @value varchar(10);
set @value = '';
SELECT COALESCE(NULLIF(@value,''), '0')

Monday, 6 November 2017

Change Selected Item Seleted

<select id="drpType" name="drpType" class="form-control" onchange="TypeChange();">
            <option value="0">--select--</option>
            <option value="Adhoc">Adhoc</option>
            <option value="Dedicated">Dedicated</option>
        </select>

<script type="text/javascript">
   
        function TypeChange()
        {         
            var selectedItem = $("#drpType option:selected").val();
            $("#drpType > [value='" + selectedItem + "']").attr("selected", "true");

        }
    </script>

Saturday, 4 November 2017

Disable TextBox And DropDownList From Code Behind

1. > For DropDownList
DropDownList1.Attributes.Add("disabled", "disabled");

2. > For TextBox
TextBox1.Attributes.Add("readonly","readonly");

3. > To Enable DropDownList Or TextBox
DropDownList1.Attributes.Remove("readonly");
TextBox1.Attributes.Remove("readonly");

Friday, 3 November 2017

TextBox And DropDownList Validation Using Javascript

<div id="divMsg" runat="server" class="alert alert-error fade in" style="display: none;">
                                        <a class="close" data-dismiss="alert" href="#">×</a>
                                        <asp:Label ID="lblMsg" runat="server"></asp:Label>
                                    </div>

<asp:Button ID="BtnSubmit" runat="server" Text="Submit" OnClick="BtnSubmit_Click"
                                        ValidationGroup="R" TabIndex="5" OnClientClick="return ValidateData();" />

function ValidateData() {
            var lblMsg = document.getElementById("<%=lblMsg.ClientID%>");
            lblMsg.innerHTML = "&nbsp;";
            var divMsg = document.getElementById("<%=divMsg.ClientID%>");
            divMsg.style.display = "none";

            var txtPrice = document.getElementById("<%=txtPrice.ClientID%>");
            var PriceValue = document.getElementById("<%=txtPrice.ClientID%>").value.trim();
            if (PriceValue == "") {
                lblMsg.innerHTML = "Enter Price!";
                divMsg.style.display = "block";
                txtPrice.focus();
                txtPrice.style.border = "1px solid red";
                return false;
            }
            else {
                lblMsg.innerHTML = "";
                divMsg.style.display = "none";
                txtPrice.focus();
                txtPrice.style.border = "1px solid #ddd";
            }

            var drpCity = document.getElementById("<%=drpCity.ClientID%>");
            var CityValue = drpCity.options[drpCity.selectedIndex].value;
            if (CityValue == "0") {
                lblMsg.innerHTML = "Please Select City!";
                divMsg.style.display = "block";
                drpCity.focus();
                drpCity.style.border = "1px solid red";
                return false;
            }
            else {
                lblMsg.innerHTML = "";
                divMsg.style.display = "none";
                drpCity.focus();
                drpCity.style.border = "1px solid #ddd";
            }
return true;
        }

File Upload Validation Using JavaScript

 <asp:HiddenField ID="hfFlag" runat="server" Value="0" ClientIDMode="Static" />
<asp:FileUpload ID="fuImages1" onchange="ValidateFileUpload(this);" runat="server"
                                                                        ClientIDMode="Static" Width="100%" />


function ValidateFileUpload(FileUploadPath) {
            if (FileUploadPath.value == '' || FileUploadPath.value == null) {
                FileUploadPath.focus();
                document.getElementById('hfFlag').value = "0";
                alert("Please upload an image");
                return false;
            }
            else {
                var Extension = FileUploadPath.value.substring(FileUploadPath.value.lastIndexOf('.') + 1).toLowerCase();

                if (Extension == "gif" || Extension == "png" || Extension == "bmp" || Extension == "jpeg" || Extension == "jpg") {
                    document.getElementById('hfFlag').value = "1";
                    return true;
                }
                else {
                    alert("Only allows file types : GIF, PNG, JPG, JPEG and BMP");
                    document.getElementById('hfFlag').value = "0";
                    FileUploadPath.focus();
                    return false;
                }
            }
        }

React Hooks - custom Hook

  v CustomHook Ø React allows us to create our own hook which is known as custom hook. Example – 1 localStorage Demo Step-1 Create ...