Sunday, April 20, 2014

How to Disable Print Screen Button Using JavaScript

Default.aspx

Write the following JavaScript code in the Page as follows.
<head id="Head1" runat="server">
<script language="JavaScript">
    function disableprintscreen() {
        var content=window.clipboardData.getData("Text");
        if (content==null) {
            window.clipboardData.clearData();}
        setTimeout("clp_clear();",1000);}
    </script>
</head>


Write the following code in the form

<form id="form1" runat="server">
<body onload='disableprintscreen()'>
<h1> disable print screen button</h1>
</body>

</form>





How To Add Attributes to DropDown and display those Attribute Values using JQUERY

Design the Form as Follows:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('#Button1').click(function(){  
                var countryId = $('#DropDownList1').find('option:selected').attr("Country");
                alert(countryId);
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>
</html>




.cs Page:

private DataRow[] _dataRow;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection con = new SqlConnection("................");
            SqlDataAdapter da = new SqlDataAdapter("select * from Employee2", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            DropDownList1.DataTextField = "FirstName";
            DropDownList1.DataValueField = "EmpID";
            DropDownList1.DataSource = ds;
            DropDownList1.DataBind();
            foreach (ListItem _listItem in DropDownList1.Items)
            {
                _dataRow = ds.Tables[0].Select("EmpID=" + _listItem.Value);
                if (_dataRow.Count() > 0)
                {
                    _listItem.Attributes["Country"] = _dataRow[0]["Country"].ToString();
                }
            }
            DropDownList1.Items.Insert(0, new ListItem("select", "0"));
        }

    }

output:



Tuesday, April 15, 2014

Convert Excel Data into DataSet


static DataSetParse(string fileName)
        {
            DataSetds = new DataSet();
            try
            {
                //Microsoft.ACE.OLEDB.12.0; Extended Properties=Excel 12.0
                stringconnectionString = string.Format("provider=Microsoft.ACE.OLEDB.12.0; data source={0};Extended Properties=Excel 12.0;", fileName);



                foreach(var sheetName inGetExcelSheetNames(connectionString))
                {
                    using(OleDbConnection con = new OleDbConnection(connectionString))
                    {
                        var dataTable = new System.Data.DataTable();
                        string query = string.Format("SELECT * FROM [{0}]", sheetName);
                        con.Open();
                        OleDbDataAdapter adapter = new OleDbDataAdapter(query, con);
                        adapter.Fill(dataTable);
                        ds.Tables.Add(dataTable);
                    }
                }
            }
            catch(Exception ex)
            {
                throwex;
            }

            returnds;

        }





        static string[] GetExcelSheetNames(string connectionString)
        {
            String[] excelSheetNames;
            try
            {
                OleDbConnectioncon = null;
                System.Data.DataTable dt = null;
                con = newOleDbConnection(connectionString);
                con.Open();
                dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);

                if(dt == null)
                {
                    returnnull;
                }

                excelSheetNames = new String[dt.Rows.Count];
                inti = 0;

                foreach(DataRow row indt.Rows)
                {
                    excelSheetNames[i] = row["TABLE_NAME"].ToString();
                    i++;
                }
            }
            catch(Exception ex)
            {
                throwex;
            }

            returnexcelSheetNames;
        }
 }

Convert DataTable to XML

Convert Data Table to XML


private static string ConvertDataTableToXML(System.Data.DataTable dtData)
        {
            DataSetdsData = new DataSet();
            StringBuildersbSQL;
            StringWriterswSQL;
            stringXMLformat;
            try
            {
                sbSQL = new StringBuilder();
                swSQL = new StringWriter(sbSQL);
                dsData.Merge(dtData, true, MissingSchemaAction.AddWithKey);
                dsData.Tables[0].TableName = "SampleDataTable";
                foreach(DataColumn col indsData.Tables[0].Columns)
                {
                    col.ColumnMapping = MappingType.Attribute;
                }
                dsData.WriteXml(swSQL, XmlWriteMode.WriteSchema);
                XMLformat = sbSQL.ToString();
                returnXMLformat;
            }
            catch(Exception sysException)
            {
                throwsysException;

            }



Working with RDLC Reports

Open visual studio

File->New Project ->Select Windows Application


And click on Ok Button.


Go to Tool Box.

Reporting

Select Report Viewer.



Now, Go to Solution Explorer

Now Add->Add New Item



Select dataset and click on Add.



Now Add->Add New Item






Go to Tool Box, and Select Table


On selecting Table the following Dataset will be displayed.




In Data source (Click on New )

Now Select DataBase.





Click on Next Button.



Click on Next Button.




Click on New Connection.



Give your Sql server Name and type of authentication.

Username and Password if selected SQL Server Authentication.


And Click on Test Connection to test the connection the connection string.




And click on Ok Button.



And select the Radio Button


And Click on Next Button.


And Click on Next Button.



And Select the Stored Procedures




And Click on Finish Button.



And Click On Ok Button.

And the following screen will be displayed in Report.



Write your Header Name

And in Data row select the Table Symbol icon and select the column Names.




 And now , go to ur form,

And select the datasource 



And run the form.

Output:




Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...