A Place to Learn Ur-self…


Example1:

  1. String rawXml =
  2.           @"<root>
  3.                 <person firstname=""Riley"" lastname=""Scott"" />
  4.                 <person firstname=""Thomas"" lastname=""Scott"" />
  5.             </root>";
  6.             XmlDocument xmlDoc = new XmlDocument();
  7.             xmlDoc.LoadXml(rawXml);

Example2:

  1. String rawXml =
  2.           @"<root>
  3.                 <person firstname=""Riley"" lastname=""Scott"" />
  4.                 <person firstname=""Thomas"" lastname=""Scott"" />
  5.             </root>";
  6.             XElement xmlDoc = XElement.Parse(rawXml);

Example3:

  1. String rawXml =
  2.           @"<root>
  3.                 <person firstname=""Riley"" lastname=""Scott"" />
  4.                 <person firstname=""Thomas"" lastname=""Scott"" />
  5.             </root>";
  6.             XDocument xd = XDocument.Parse(rawXml);


Sample XML:

  1. <Employees>
  2.   <Employee Id="1" EmpName="Chikkanti" Sal="2000"/>
  3.   <Employee Id="2" EmpName="Karthik" Sal="2500"/>
  4.   <Employee Id="3" EmpName="Kishore" Sal="3000"/>
  5.   <Employee Id="4" EmpName="Raju" Sal="3500"/>
  6. </Employees>

(Method 1)Sample Code to delete XML Node Using linq C#:

  1. using System;
  2. using System.Linq;
  3. using System.Xml.Linq;
  4. using System.Xml.XPath;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             //Loading XML file
  13.             XElement xdoc = XElement.Load("D:/Employees.xml");
  14.             //Selecting XML Node to delete
  15.             var x = (from elemet in xdoc.Elements("Employee")
  16.                      where elemet.Attribute("Id").Value == "1"
  17.                      select elemet);
  18.             Console.Write(xdoc);
  19.             //Removing XML Node
  20.             x.Remove();
  21.             Console.Write(xdoc);
  22.         }
  23.     }
  24. }

(Method 2)Sample Code to delete XML Node Using linq C#:

 

  1. using System;
  2. using System.Linq;
  3. using System.Xml.Linq;
  4. using System.Xml.XPath;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             //Loading XML file
  13.             XElement xdoc = XElement.Load("D:/Employees.xml");
  14.             Console.Write(xdoc);
  15.             //Removing XML Node
  16.             xdoc.XPathSelectElement("Employee[@Id = '1']").Remove();//Add System.Xml.XPath for XPathSelectElement
  17.             Console.Write(xdoc);
  18.         }
  19.     }
  20. }


We have may plug-ins to read Query string values in JavaScript. But we don’t know what is happening inside plug-in.

let’s learn how to read Query String values with plain JavaScript.

Example URL:

Script to read Query String Value.

<script type="text/javascript">
    function getParameterByName(name) {
        name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
            results = regex.exec(location.search);
        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
</script>

Method Call:

  1. var postNo = getParameterByName("PostNo");//OutPut:100


Originally posted on Journey to SQL Authority with Pinal Dave:

Note: If you want to practice the code and the example along with here, you can download dbForget Studio from here.

Everyone, who is involved in work with databases, eventually faces with data export/import tasks. Unlike data import tasks, data export has to be performed in various formats, depending on the business requirements of customers. SSMS capabilities allow saving selection result in the CSV format or as a text file with delimiters. Moreover, SQL Server supports the OPENROWSET construct, which usage enables export to XLS files. However, this functionality was scarcely enough for me to perform current tasks. In order to resolve the situation and meet customers’ requirements, I had to automate the export process using dynamic SQL.

At first, such an approach justified itself. For example, here is an HTML markup generating script for a random table/view:

USE AdventureWorks2012;
DECLARE
@object_name SYSNAME
, @object_id INT
, @record_count INT
,

View original 599 more words


Originally posted on Justin Cooney:

Have you ever wanted to help your users move data from Excel to your Web application? In this article I will give an example in ASP.NET that takes copied Excel spreadsheet rows from the user’s clipboard and saves the information to a SQL Server database table.

Since ASP.NET runs at the server level, you will need to use JavaScript/JQuery to get the Excel information from the user’s clipboard. You will need to use a different command to get the information depending on the user’s browser. In this example, I code specifically for Internet Explorer, but this is just since I am giving an example. In a real-world application you would code for all of the major browsers.

View original 839 more words


If you are working with files in asp.net it is better to Store the files on the file system and filepath in the database. In many situations, databases are stored on fast (read: expensive storage, 15k RPM or SSD drives) storage. Images or other files, typically can be stored on slower (read: cheaper, larger drives, 7.2k RPM drives) storage.

Because…

  1. You can access files faster
  2. easier to configure security settings
  3. No size limitation
  4. You will be able to serve the pictures as static files.
  5. No database access or application code will be required to fetch the pictures.
  6. The images could be served from a different server to improve performance.
  7. you don’t get into any trouble, if you have to migrate your back end.
  8. It will reduce database bottleneck.
  9. The database ultimately stores its data on the file system.
  10. Images can be easily cached when stored on the file system.

still if you want to store files in DataBase only, better to use FileStream field type which can provide the best of both worlds.


Subject: Here we can Learn how to Handle Double click event of Asp.Net controls using Jquery, here i will explain with asp.net button control

If you are New to Jquery Start from here.

first take new asp.net empty website and add jquery library to website and add one asp.net webform and write following code

JQuery Script:

<script type="text/javascript">
        $(function () {
            $("input[id$=Button1]").bind({
                click: function (e) {
                    e.preventDefault();
                },
                dblclick: function () {
                    alert("DoubleClick Happed to Button");
                }
            });
        });
    </script>

CompleteCode:

<%@ Page Title="Handling DoubleClick of Asp.Net Button" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="HandlingDoubleClick.aspx.cs" Inherits="HandlingDoubleClick" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script src="Scripts/jquery-1.7.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("input[id$=Button1]").bind({
                click: function (e) {
                    e.preventDefault();
                },
                dblclick: function () {
                    alert("DoubleClick Happed to Button");
                    //write ur code here
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Button ID="Button1" runat="server" Text="Double click on me" />
</asp:Content>

Explanation:

Here i am explaining Example with Master pages, the reason is, when the asp.net webform renders as html in browser it will assign dynamic ids for asp.net controls while merging master page and content page. Here why asp.net assigning dynamic ids, because to avoid naming collision

so here we have to use

$("input[id$=Button1]")

this statement to get asp.net control with dynamic id

and Bind method will bind events to control, here we are binding click and double click events

Click Event:

click: function (e) {
                    e.preventDefault();
                },

in this click event we are preventing default behavior of asp.net button control, i.e preventing post back

Double click Event:

dblclick: function () {
                    alert("DoubleClick Happed to Button");
                    //write ur code here
                }

in this double click event write your code…

 

Happy Coding….

If u have any drought feel free to contact from AboutMe page