Monday, 16 November 2015

genrate dinamic slider using aps.net C# with css and JS (wowslider)


// get css from wowslider
// get JS from wowslider



protected void generate_slider()
    {
        string paths = Server.MapPath("FolderName");
        DirectoryInfo d = new DirectoryInfo(paths);
        FileInfo[] Files = d.GetFiles("*");
        HtmlImage img;
        HtmlGenericControl li;
        foreach (FileInfo file in Files)
        {
            string filename = file.Name;// file name find
            string[] str = filename.Split('_');// split with your condtion
            if (str[0] == "check id condition here")
            {
                li = new HtmlGenericControl("li");
                img = new HtmlImage();
                img.Src = "Photo Gallery/" + filename;
                img.Style.Add("min-height:50px; max-height:250px; min-width", "20%");
                img.Alt = "";
                img.ID = str[0] + "" + str[1];
                li.Controls.Add(img);
                sliderid.Controls.Add(li); 
//add htmlgenericcontrol with server control here 'sliderid= server control id'
            }

        }

// reference

Get all files from directory folder using asp.net c#


// Add namespace

using System.IO;

// listed files

       // 1. for all files of directory folder

       public void getfiles()
    {
        string targetDirectory = Server.MapPath("slider/images");
        DirectoryInfo d = new DirectoryInfo(targetDirectory);//get directory folder
        FileInfo[] Files = d.GetFiles("*"); //get all files from Folder
        string str = "";
        foreach (FileInfo file in Files)
        {
            str = str + "" + file.Name + ", ";
        }

    } 

 // 2. for selected extension files only of directory folder

    public void getfiles()
    {
        string targetDirectory = Server.MapPath("slider/images");
        DirectoryInfo d = new DirectoryInfo(targetDirectory);//get directory folder
        FileInfo[] Files = d.GetFiles("*.jpg");//get all files from Folder
        string str = "";
        foreach (FileInfo file in Files)
        {
            str = str + "" + file.Name + ", ";
        } 
    }

Friday, 13 November 2015

JavaScript : Restrict multiple time entry of and char or number or decimal using javascript on keydown


// HTML

<input type="text" class="decimal" value="" />
            
 or

<asp:TextBox ID="txt_actID" runat="server">

///////  JS

$('input').on('keydown', function (event) {
                return isNumber(event, this);
            });

            function isNumber(evt, element) {
                var charCode = (evt.which) ? evt.which : evt.keyCode;
                if ((charCode != 190 || $(element).val().indexOf('.') != -1) && (charCode != 110 || $(element).val().indexOf('.') != -1)
                && ((charCode < 48 && charCode != 8) || (charCode > 57 && charCode < 96) || charCode > 105))
                    return false;
                return true;
            }


/////////////////or

<asp:TextBox ID="TextBox1" runat="server"   onkeydown="return isNumber(event, this);">

/// js

 function isNumber(evt, element) {
                var charCode = (evt.which) ? evt.which : evt.keyCode;
                if ((charCode != 190 || $(element).val().indexOf('.') != -1) && (charCode != 110 || $(element).val().indexOf('.') != -1)
                && ((charCode < 48 && charCode != 8) || (charCode > 57 && charCode < 96) || charCode > 105))
                    return false;
                return true;
            }


Tuesday, 10 November 2015

JavaScript : Restrict multiple time entry of and char or number or decimal using javascript on keypress



// HTML

<asp:TextBox ID="TextBox1" runat="server"   onkeypress="return isNumber(this, event);">


// JS

<script type="text/javascript">
function Is_Double_Exits(obj, event) {
            debugger;
            var charCode = (event.which) ? event.which : event.keyCode;
            if (charCode == 46) {   // keycode of decimal
                if (obj.value.indexOf('.') === -1) {
                    return true;
                }
                else {
                    return false;
                }
            }
            else {
                if (charCode > 31 && (charCode < 48 || charCode > 57)) {
                    return false;
                }
                else {
                    return true;
                }
            }
return true;
        }
</script>

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...