Recent Posts
- November 2014 (1)
- January 2014 (1)
- October 2013 (1)
- May 2013 (1)
- February 2013 (2)
- October 2012 (1)
- August 2012 (1)
- July 2012 (4)
- June 2012 (13)
Blog Stats
- 36,360 hits
Write your code smartly
To define a class in CSS the format used is : put a (dot) first followed by any name you want to put for a class.
.textcolor {
color: #FFF;
}
can be used like this in a paragraph tag for instance
<p class="textcolor"> This is CSS class <p>
The result will be the text written inside paragraph tag will have white foreground or text color.
Now defining a CSS class ID, put # symbol followed by a desired name of class ID
#contentsection {
height: 767px;
width: 1003px;
margin: auto;
padding: 0px;
background-position:center center;
}
using it like this for instance
<div id="contentsection"></div>
It will create a div section on the page with defined properties in the Class ID.
Now what is the difference between these two types of classes which works almost same.
The main difference between these two types of CSS declaration is that class ID can be used only once as it is just as unique identifier for a person which can only be a one person with one ID. But class can be used multiple times in your body of the page. So class is used when you want to apply that css style to a item which will be used many times but if one time then you can use ID. Also when calling class ID in a tag you must specify it by calling its ID property like this
<div id="contentsection">
but when calling a class we use class property
<p class="textcolor">
Here I am going to guide you about how to create web service in .net framework 3.5. You can create this web service in Visual Studio by selecting new project > and target framework 3.5 and select web service from the list. This web service will retrieve data from SQL server database and response a XML version of it.
Here is the web.config connection string:
Windows Authentication:
<appSettings> ConnectionString(name of your choice)" value="Data Source=server name;Initial Catalog=DB name;Integrated Security=SSPI;"/> </appSettings>
Now, open your “service1.asmx.cs” file and put the following code inside the namespace.
[Web Service(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
string dbConnString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
[WebMethod]
public XmlDocument getDataXML(string strQuery, string strRootNode, string strItemNode)
{
// Create vars out of connection string and query string
string dbConn = dbConnString;
string dbQuery = strQuery;
// Connect to the database and run the query
SqlConnection conn = new SqlConnection(dbConn);
SqlCommand cmd = new SqlCommand(dbQuery, conn);
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
ds.DataSetName = strRootNode;
da.SelectCommand = cmd;
da.Fill(ds, strItemNode);
// Return the data as XML
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(ds.GetXml());
return xmlDoc;
}
}
To check, run the code and click the link getDataXML and provide the query you want to execute and tags you want to receive the data in and click invoke.
For example:
strQuery= select * from Users; strRootNode= Node strItemNode= Record
Output:
<Node> <Record> <LoginId>7</LoginId> <LoginName>Administrator</LoginName> <Email>admin@admin.com</Email> <Username>admin</Username> <Password>admin</Password> <Rights>1</Rights> <ModifiedDate>2008-06-15T00:00:00+05:00</ModifiedDate> </Record> <Record> <LoginId>9</LoginId> <LoginName>Jibran</LoginName> <Email>ji_jibran1990@hotmail.com</Email> <Username>Jibs</Username> <Password>abc</Password> <Rights>1</Rights> <ModifiedDate>2008-06-15T00:00:00+05:00</ModifiedDate> </Record> </Node>