Posted on May 7, 2008 by Siemen
This post shows you how to return XmlDataDocument from the database.
This helps you to fetch the xml data created in sql and use in asp.net.
If you are familiar how to get xml data from sql then this post helps you to fetch the xml data in XmlDataDocument.
//Code Starts Here
// http://helpindotnet.blogspot.com/
// http://helpindotnet.wordpress.com
public XmlDataDocument getauditnames(string prefixText, int [...]
Filed under: asp.net c#, sql, xml | Tagged: get xml from sql, sql from xml, xml, xml from database, xmldatadocument | Leave a Comment »
Posted on May 6, 2008 by Siemen
<span style=”font-weight:bold;”>Here I will show you the easiest way to compress and Decompress (Gzip) a file using Asp.net with c#.
You can compress any file with this method.</span>
//Code Starts here
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO.Compression;
/*
* http://helpindotnet.blogspot.com/
*/
namespace ConsoleApplication1
{
class GZipTest
{
private const int buffer_size = 100;
public static int ReadAllBytesFromStream(Stream stream, byte[] buffer)
{
// Use this method is used to read [...]
Filed under: asp.net c# | Tagged: compress a file, compress file, gzip, GZip Compress Decompress | Leave a Comment »
Posted on May 6, 2008 by Siemen
<span style=”font-weight:bold;”>This is a short and sweet little tutorial to show you how to dynamically insert a new Javascript (or style sheet) into your web pages</span>
FOR CSS…
var headID = document.getElementsByTagName(“head”)[0];
var cssNode = document.createElement(‘link’);
cssNode.type = ‘text/css’;
cssNode.rel = ’stylesheet’;
cssNode.href = ‘FireFox.css’;
cssNode.media = ’screen’;
headID.appendChild(cssNode);
FOR JAVASCRIPT…
var headID = document.getElementsByTagName(“head”)[0];
var newScript = document.createElement(’script’);
newScript.type = ‘text/javascript’;
newScript.src = ‘http://www.somedomain.com/somescript.js’;
headID.appendChild(newScript);
Filed under: javascript css | Tagged: css injection, dynamic insert css, dynamic insert javascript, head appendChild, javascript injection | Leave a Comment »
Posted on May 6, 2008 by Siemen
<span style=”font-weight:bold;”>Send Mail Messages Using System.Net.Mail namespace (new in .net Framework Version 2.0) which provides classes that enable you to easily create and transmit e-mail messages.</span>
Asp.net c#:
// Create a MailMessage object
MailMessage mm = new MailMessage();
// Define the sender and recipient
mm.From = new MailAddress(fromEmailAddress.Text, fromDisplayName.Text);
mm.To.Add(new MailAddress(toEmailAddress.Text, toDisplayName.Text));
// Define the subject and body
mm.Subject = subjectTextBox.Text;
mm.Body = bodyTextBox.Text;
mm.IsBodyHtml [...]
Filed under: asp.net c# | Tagged: asp.net send mail, c# send mail, mail using .net, MailMessage object, System.Net.Mail | 2 Comments »
Posted on May 6, 2008 by Siemen
<span style=”font-weight:bold;”>While coding with XML Files, Sometimes you need to Encode and Decode the Xml Name.
Here is the simplest method to encode the name XmlConvert.EncodeName(string).
</span>
using System.Xml;
namespace ConsoleApplication1
{
class classEncodeDecodeXMLName
{
static void encodedecode()
{
// Encode and decode a name with spaces.
Console.WriteLine(XmlConvert.ToByte(“Some Name”));
string name1 = XmlConvert.EncodeName(“Order Detail”);
Console.WriteLine(“Encoded name: ” + name1);
Console.WriteLine(“Decoded name: ” + XmlConvert.DecodeName(name1));
// Encode and decode a local [...]
Filed under: xml | Tagged: decode xml, encode xml, encode xml name, xmlconvert, XmlConvert.EncodeName | Leave a Comment »
Posted on May 6, 2008 by Siemen
ASCII does’nt recognizes the unicode character. Unicode code character are different from special character. For Ex: scientific characters like pi, pmu,…
Unicode Character is : Pi : Π
Try out with different unicode characters
//Code starts here
static void convertunicode()
{
string unicodeString = “This string contains the unicode character Pi(\u03a0)”;
// Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
// [...]
Filed under: Asp.net, c#, mssql, XML | Tagged: ascii to unicode, convert ascii, convert unicode, unicode, unicode characters | Leave a Comment »
Posted on May 2, 2008 by Siemen
Here I will show you how to “Validate Xml against the provided Schema xsd”.
This is the simplest method to validate the xml from the given Schema xsd
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Data;
using System.Web;
namespace ConsoleApplication1
{
class clsValidateXml
{
public static string ErrorMessage=””;
static void validatexml()
{
//Physical path of the XML File
string XmlFilePath = @”c:\Test.xml”;
//Physical path of the XSD File
string XSDFilePath = @”c:\Test.xsd”;
XmlDocument [...]
Filed under: xml | Tagged: schema, validate xml, xml | Leave a Comment »