Thursday, July 30, 2009

HOW TO REMOVE PRINTER DRIVER

You can remove printer driver by following steps that are defined below:

1. Go to Printers & Faxes

2. Delete the printer configuration in question. (For safety's sake, you may want to consider deleting all printer configurations to ensure that you aren't still using some element of the driver in another configuration somewhere. Remember that a driver is often times more than just a single file. It may involve shared libraries in use by multiple printer configurations.)

3. Go to File --> Server Properties

4. Go to the Drivers tab. You will be presented with a list of drivers.

5. Select a Driver and press the "Remove" button.

Tuesday, July 28, 2009

\\server is not accessible. You might not have permission to use this network resource. Contact the administarator of this server to find out if you

Problem:

Often time I receive a problem while my computer is connected with networks.It work properly on server 5 minutes ago but after 5 minutes it display me the error.

"\\server is not accessible. You might not have permission to use this network resource. Contact the administarator of this server to find out if you have access Permissions. Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again."

I digged alot about the solution of the problem. Some post suggest block your firewall which I was not using and many other solution. But nothing work.

After a long hours of digging on web for the above problem and implementing all the solutions that they suggest in their post, I have found a valuable command which solve my problem and now I am not facing this problem and if some time I face then use the solution.


Oh........ I forget the share solution with you. The solution is based on commands and they are (Open your command prompt first)

1) net use * /d

The above command will remove all the map drives from your computer. After writing this command and press enter, it will ask you that to press 'y' for Yes and 'n' for No. Press y. After then write the next command

2) net use h:\\server_name\foldername

Now wait for a few seconds / minutes (might be). It will ask the user name and password. Enter the user name and password and get rid from the problem.

Hope this will work for you as well.

Best of Luck.

OUTLOOK CANNOT CONNECT TO YOUR OUTGOING SMTP EMAIL SERVER.

Dear Friends,

I am using MS OUTLOOK for my Email. It was working fine but since last day it is giving me an error.

"Outlook can not connect to your outgoing SMTP E-mail server. If you continue to recieve this message contact your Administrator or ISP Provider."


After digging long hours I get some solutions.

1) Change smtp port from 25 to 587.

OR

2) create the account again.

OR

3) Check Firewalls either they are not creating the problem.

OR

4) If any of the above options is not working then contact to your ISP Provider. Either they have block the SMTP address from their side. Ask them to allow your SMTP to send E-mails.

In my case the fourth option works.

I hope that this will help you in solving the problem.

Wish you all the best............

CONNECTION STRING IN WEB.CONFIG IN C#

Dear Fellows,

You can create declare connection string in web.config file. You can do so by

<add name="Connection_Name" connectionString="server=(local);database=database_name;uid=sa;pwd=sa" providerName="System.Data.SqlClient"/>

Now you can call this connection in any .aspx page by this command.

NOTE: I am getting connection string in a string variable named "Path"

string path = System.Configuration.ConfigurationManager.ConnectionStrings["Connection_Name"].ConnectionString;

See how simple is this. In the same way you can use this connection string in all your .aspx pages.

Take Care and Enjoy...............

Thursday, July 16, 2009

The TargetControlID of '_AccordionExtender' is not valid. The value cannot be null or empty.

Once I was working with a Ajax Based Project in .NET. I was using Accordian Pane. My code was like this (Please note this is just a sample code only for readers):

<ajaxToolkit:Accordion runat="server" TransitionDuration="240" FadeTransitions="true" FramesPerSecond="40" SelectedIndex="0" >
<Panes>
<ajaxToolkit:AccordionPane ID="hd1" runat="server">
<Header>
<a href="" onclick="return false" >HEADER 1</a>
</Header>
<Content>
CONTENT OF HEADER 1
</Content>
</ajaxToolkit:AccordionPane>


<ajaxToolkit:AccordionPane ID="hd2" runat="server">
<Header>
<a href="" onclick="return false" >HEADER 2</a>
</Header>
<Content>
CONTENT OF HEADER 2
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>

And I was facing an Error saying

"The TargetControlID of '_AccordionExtender' is not valid. The value cannot be null or empty."

After digging a little bit I found that I have not provided ID to Accordian

<ajaxToolkit:Accordion id="accordian1" runat="server" TransitionDuration="240" FadeTransitions="true" FramesPerSecond="40" SelectedIndex="0" >
<Panes>
<ajaxToolkit:AccordionPane ID="hd1" runat="server">
<Header>
<a href="" onclick="return false" >HEADER 1</a>
</Header>
<Content>
CONTENT OF HEADER 1
</Content>
</ajaxToolkit:AccordionPane>


<ajaxToolkit:AccordionPane ID="hd2" runat="server">
<Header>
<a href="" onclick="return false" >HEADER 2</a>
</Header>
<Content>
CONTENT OF HEADER 2
</Content>
</ajaxToolkit:AccordionPane>
</Panes>
</ajaxToolkit:Accordion>

After providing ID to Accordian its works fine..................

I hope that this post will also help you.

Wednesday, July 15, 2009

HOW TO CONVERT A STRING INTO DATE IN VB.NET OR C#

To Convert a String into Date Format we need date.parseexact() Function.

date.parseExact(date as string, format as string, third attribute)

example

date.parseExact(stDate, "MM-dd-yyyy", nothing)

That's all......... Enjoy.............

WEBCONFIG FILE FOR AJAX IN ASP.NET 2.0 , ASP.NET 3.0 AND ASP.NET 3.5

Dear Friends,


When I have installed VSTS 2008 in my PC, I faced problem in using Ajax Files. I follow all the instructions that was told in vidoes on www.asp.net\learn but no result.


After investing a number of days and hours, I come to the conclusion that I must have to see my old Ajax Projects WebConfig files. When I compare my existing projects webconfig files and old webconfig files I found that they have no Commands to work with Ajax Based Controls.


The reason to publish this webconfig file is to save others time as they might face some time the same problem which I faced and wasted my time.


Below is the entire webconfig file. Simply copy it in your webconfig file or change it as per your need.



<?xml version="1.0"?>

<configuration>

<configSections>

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>

<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup>

</sectionGroup>

</sectionGroup>

</configSections>

<system.web>

<pages>

<controls>

<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>

<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls>

</pages>

<!--

Set compilation debug="true" to insert debugging

symbols into the compiled page. Because this

affects performance, set this value to true only

during development.

-->

<compilation debug="true">

<assemblies>

<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies>

</compilation>

<httpHandlers>

<remove verb="*" path="*.asmx"/>

<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>

</httpHandlers>

<httpModules>

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</httpModules>

</system.web>

<system.web.extensions>

<scripting>

<webServices>

<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->

<!--

<jsonSerialization maxJsonLength="500">

<converters>

<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>

</converters>

</jsonSerialization>

-->

<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->

<!--

<authenticationService enabled="true" requireSSL = "true|false"/>

-->

<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved

and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and

writeAccessProperties attributes. -->

<!--

<profileService enabled="true"

readAccessProperties="propertyname1,propertyname2"

writeAccessProperties="propertyname1,propertyname2" />

-->

</webServices>

<!--

<scriptResourceHandler enableCompression="true" enableCaching="true" />

-->

</scripting>

</system.web.extensions>

<system.webServer>

<validation validateIntegratedModeConfiguration="false"/>

<modules>

<remove name="ScriptModule"/><add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</modules>

<handlers>

<remove name="ScriptHandlerFactory"/>

<remove name="ScriptHandlerFactoryAppServices"/>

<remove name="ScriptResource"/><remove name="WebServiceHandlerFactory-Integrated"/>

<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

</handlers>

</system.webServer>

<system.codedom>

<compilers>

<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">

<providerOption name="CompilerVersion" value="v3.5"/>

<providerOption name="WarnAsError" value="false"/></compiler>

<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">

<providerOption name="CompilerVersion" value="v3.5"/>

<providerOption name="OptionInfer" value="true"/>

<providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>

<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<dependentAssembly>

<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>

<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>

<dependentAssembly>

<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>

<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>

Wednesday, July 1, 2009

How to Insert a new Node in XML File in C#

This is 4th post regarding XML. In this, I will teach you how to insert a new node in XML file.

The sample XML file is shown below which is before Inserting new Node.

<?xml version="1.0"?>
<Library>
<Subjects name="Computer Science">
<Publishers name="Wrox">
<Begginers>Beginning C#</Begginers>
</Publishers>
</Subjects>
</Library>


Now write the below code to insert a new node in XML.

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(filename);
//Create New Element
XmlElement element = xmldoc.CreateElement("Begginers");
element.InnerText = "BEGINNER C# (INDIAN WRITER)";
//Insert Node after Publishers
xmldoc.DocumentElement["Subjects"].ChildNodes[0].InsertAfter(element, xmldoc.DocumentElement["Subjects"].ChildNodes[0].LastChild);
FileStream fsxml = new FileStream(filename, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
xmldoc.Save(fsxml);
Console.WriteLine("XML Updated Successfully");


After executing this code you will get the following output.

<?xml version="1.0"?>
<Library>
<Subjects name="Computer Science">
<Publishers name="Wrox">
<Begginers>Beginning C#</Begginers>
<Begginers>BEGINNER C# (INDIAN WRITER)</Begginers>
</Publishers>
</Subjects>
</Library>

How to Insert an New Element in XML File in C#

This is my third post in which I tell you how to Insert an Element in XML file.

The sample XML file is shown below

<?xml version="1.0"?>
<Library>
<Subjects name="Computer Science">
<Publishers name="Wrox">
<Begginers>Beginning C#</Begginers>
</Publishers>
</Subjects>
</Library>


Now you write the code to insert a new Element.

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(filename);
//New XML ELEMENT Created
XmlElement xElement = xmldoc.CreateElement("Publishers");

//NEW XML ATTRIBUTE Created
XmlAttribute xAttribute = xmldoc.CreateAttribute("name");
xAttribute.Value = "Indian Book";
xElement.SetAttributeNode(xAttribute);

//Create Inner Element
XmlElement element = xmldoc.CreateElement("Begginers");
element.InnerText = "BEGINNER C# (INDIAN WRITER)";
xElement.AppendChild(element);
xmldoc.DocumentElement.InsertAfter(xElement, xmldoc.DocumentElement.LastChild);

FileStream fsxml = new FileStream(filename, FileMode.Truncate, FileAccess.Write, FileShare.ReadWrite);
xmldoc.Save(fsxml);
Console.WriteLine("XML Updated Successfully");



After executing this code. you will get the following output xml.

<?xml version="1.0"?>
<Library>
<Subjects name="Computer Science">
<Publishers name="Wrox">
<Begginers>Beginning C#</Begginers>
</Publishers>
</Subjects>
<Publishers name="Indian Book">
<Begginers>BEGINNER C# (INDIAN WRITER)</Begginers>
</Publishers>
</Library>

How TO READ XML IN C#

This is my Second post regarding XML. In first post i told you that how to create a xml file in C#. Now we will learn that how can we read a xml file in c#.

To read an XML file in c# you need to add a namespace.

using System.XML;

Now write the below code to read xml file.

XmlTextReader reader = new XmlTextReader(filename);
reader.Read();
while (reader.Read())
{
if(reader.Value.Trim()!="")
Console.WriteLine("Attribute Count={0}, Attribute={1}, Value={2}", reader.AttributeCount, reader.GetAttribute("name"),reader.Value);
}



I used this code to get my result which I want. You can modify the code to get yours one.

Enjoy..........

HOW TO WRITE XML IN C#

Below is the code in C# which you can use to create an XML file.



Note: You must include System.XML namespace. You can do so by writing the below command.

using System.XML;

The sample of XML is shown below:

<?xml version="1.0"?>
<Library>
<Subjects name="Computer Science">
<Publishers name="Wrox">
<Begginers>Beginning C#</Begginers>
</Publishers>
</Subjects>
</Library>

Now write the below code to get the above result.

XmlTextWriter writer = new XmlTextWriter(filename, null);
//SELECT THE FORMATTING STYLE (INDENTED, NONE)
writer.Formatting = Formatting.Indented;
//STARTING TAG
writer.WriteStartDocument();
//STARTING "Root"
writer.WriteStartElement("Library");
//STARTING ELEMENT NAMED "COMPUTER SCIENCE"
writer.WriteStartElement("Subjects");
writer.WriteAttributeString("name", "Computer Science");
//FURTHER ELEMENT NAMED "COMPUTER SCIENCE"
writer.WriteStartElement("Publishers");
writer.WriteAttributeString("name", "Wrox");
writer.WriteStartElement("Begginers");
writer.WriteString("Beginning C#");
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Close();
Console.WriteLine("XML Written Successfully");

Docker Tutorial

 I have listed all the necessary commands of Docker below. In case if any is missing or if any improvement required, please share in comment...