.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

selecting value from non-existing node

Posted By:      Posted Date: September 06, 2010    Points: 0   Category :ASP.Net
Im using XSL to retrieve a value from XML.Label1.Text = nodeList(0).SelectSingleNode("str[@name=""website""]").InnerTextBut it might be that the node <str name="website"> does not exist for the currently selected parentnode.In that case the above line will throw an error.Is there an easy way to ignore this?So that if no value can be found, just pass an empty string "" to Label1.Text?I tried using ToString, but without luck:Label1.Text = nodeList(0).SelectSingleNode("str[@name=""website""]").InnerText

View Complete Post

More Related Resource Links

add an XML node to an existing XMLdocument

I want to add an XML node (locationNode) to an existing XMLdocument (xmldoc)However, I get the error: The node to be inserted is from a different document context.Which makes sense, but then I dont know how I can do what I want.Here's my code:Dim doc As XmlDocument = New XmlDocument()Dim locationNode As XmlNode = doc.CreateElement("location")Dim locationAttribute As XmlAttribute = doc.CreateAttribute("id")locationAttribute.Value = "3"locationNode.Attributes.Append(locationAttribute)'doc.AppendChild(locationNode)Dim titleNode As XmlNode = doc.CreateElement("title")titleNode.AppendChild(doc.CreateTextNode("Opera house"))locationNode.AppendChild(titleNode)xmldoc.AppendChild(locationNode)contents of xmldoc:    <root>    <data>        <compare>            <locations>                <location id="4">                    <title>Empire state building</title>                </location>                <location id=&quo

Adding a full node to an existing XML document on a by xpath specified location

I want to add a complete node to an existing XML document.So:1. get the XML document from the session2. create a new node3. pass the node and the session to a function, that adds the node on the location of the xpath4. return the new session, updated with the node in the specified locationBelow my code, which DOESNT work.I've had some other advices, but nothing seems to work. What am i doing wrong?!?!Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    Dim doc As XmlDocument = New XmlDocument()    Dim xmldoc As XmlDocument = Session("XML") 'get XMLdocument from session    Dim locationNode As XmlNode = doc.CreateElement("location")    Dim locationAttribute As XmlAttribute = doc.CreateAttribute("id")    locationAttribute.Value = "3"    locationNode.Attributes.Append(locationAttribute)    Dim titleNode As XmlNode = doc.CreateElement("title")    titleNode.AppendChild(doc.CreateTextNode("Empire State Building"))    locationNode.AppendChild(titleNode)    doc.AppendChild(locationNode)    Dim newNode As XmlNode = doc.ImportNode(locationNode, True)    AddOrUpdateNodeInSession(Session, "//root/dat

TreeView node visually unselected after selecting tree node and then clicking soem other field



I am using .NET 3.5 (VS 2008).  I have a SplitContainer with a TreeView on one side and a form with various fields, tabs, etc on the other.  When I select one of the tree nodes, the node is highlighted.  The node loses its highlighting when the user clicks on one of the tabs or enters a field on the other side of the SplitContainer.  Although no highlighting is visible, the treeView.SelectNode() still returns the proper node, so it appears that the tree node is still selected, just not visually highlighted.  The problem is that without the highlighting to distinguish which node is selected, the user can easily get lost.  Is there a build-in mechanism to maintain some sort of highlighting on the selected node when the cursor is moved to another form.  For example, in Windows Explorer, if you select a tree node, the node is highlighted in a dark blue.  If you were to then place the cursor in the Address box, the selected node changes to have a beige color.  This still shows which node was selected.

Is there a built-in solution (ie some property to set on the tree view or nodes) that would help fix my issue or do I have to build my own solution to mimic something like what Windows Explorer does?  I wanted to avoid having to put event handlers on all tabs and form fields that would be used to &

Getting "A domain group is missing for one or more services" error when adding new node to existing


Hey all,

Current configuration:

2-node sql 2005 cluster

windows 2003 enterprise R2 w/ sp2 x64

sql 2005 enterprise x64 SP3


In the process of adding a third node into the existing 2-node cluster, we received the

"A domain group is missing for one or more services.  To install SQL 2005 as a failover cluster, domain groups must be specified for all the clustered services bing installed. To proceed, enter the missiong domain group information." 

The existing cluster functions properly and has been running w/o problems for a long while now.  An AD Global Group was created to support the cluster back when the cluster was initially created.


I found different suggestions from people online about this issue, any where from adding registry keys to take trailing blank space from sql resource group name, but none works. 


Any ideas?


Thank you in advance for any assistance.



savefiledialog and openfiledialog: Selecting existing file or creating a new one


In my application (C#) users need to select existing file or create new file where they want to save some data. Existing files are in read-only mode because they are under Perforce subversion source control. I'm going to handle file checkout in my application automatically after user has selected the file where he wants to save data (or if file is new file, application adds it to source control).

The problem is that I can't use savefiledialog, because it complains about selected file being read-only. I could use openfiledialog, but it has couple problems. First problem is that openfiledialog confirm button has text "Open", which is something i could live with even though it would be better if it read "Save" :)

Second and bigger problem is when you want to create new file in openfiledialog. I set CheckFileExists to false so when user writes file name and presses "Open"-button, openfiledialog doesn't complain about file because it doesn't exist and it returns path to "new" file just fine. But problem is that if user has clicked or selected to some folder in openfiledialog and then writes file name and presses "Open"-button, openfiledialog just opens selected folder.

So basically I just need some file browsing dialog which works like savefiledialog but doesn't complain about read-only, i just need to

SQL 2005 Standard to Enterprise Edition upgrade on existing three-node cluster


Current set-up: three node cluster running Windows Server 2003 Enterprise Edition SP2 with two instances of SQL Server 2005 Standard Edition SP2.


Virtual node 1: Standard Edition, default instance, Database Engine only

Virtual node 2: Standard Edition, named instance, Database Engine, Analysis Services and Integration Services


Physical node A: Prefered node for virtual node 1

Physical node B: Failover node for both virtual node 1 and 2 (thus having two installations of Standard Edition)

Physical node C: Prefered node for virtual node 2


We started off with this set-up because there was no need for Enterprise features, and SQL 2005 supports failover clustering with two nodes in Standard Edition. Saved a bundle of cash, so everybody's happy. Now we need to run a solution on virtual node 2 that requires Enterprise features in Analysis and Integration Services, so an edition upgrade is required on virtual node 2. I have done some research and found several edition upgrade examples, but none that match the above scenario. We are running production on these machines, so I can't risk experimenting with command line options, I have to be right the first time.


Is it possible to mix two editions of SQL Server 2005 in one cluster? Can I upgrade virtual node 2 to Enterprise but leave virtual node 1 at

adding a node to existing SQL Server 2000 cluster


We have a SQL 2000 cluster pair, say node A and node B. The node B has been corrupted and now the SQL instance is running only on node A. The node B has been rebuilt from scratch and OS reinstalled.

Now, we need to add the node B to node A and they should have a SQL cluster pair. Any one can provide any steps how to add this newly built node to an existing SQL 2000 cluster.

How to check for existing node while writing in XML file ?



         I have to add a node each time the compiler passes through the following code :

         string XMLFilePath = System.Web.Hosting.HostingEnvironment.MapPath("~/Log/log.xml").ToString();

            if (File.Exists(XMLFilePath))
                XmlTextWriter xmlWriter = new XmlTextWriter(XMLFilePath, System.Text.Encoding.UTF8);
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
                xmlWriter.WriteElementString("error", "No file input");

URL Routing and Existing HttpHandler problems


Hello everyone,

I have a problem:

I am currently using 2 features: 

1. HttpHandler

Registering the path="res.aspx" verb="*"

2. URL Routing:

Registering with this pattern: "Company/Edit/{*companyId}","~/CompanyEdit.aspx"

In my CompanyEdit.aspx page, I used httphandler res.aspx to generate some images at client.

  • res.aspx?img=1
  • res.aspx?img=3

Now the problem is here, the page is load success with companyId = "12345", but when the images was loaded at client, it loaded the CompanyEdit.aspx again and show error with wrong id.  

I have debug and find the problem that because when image's urls were generated to client with url=res.aspx?img=1, url=res.aspx?img=3, the asp.net will understand that they are Company/Edit/res.aspx?img=1, Company/Edit/res.aspx?img=3 when it maps with URL Routing pattern.

=> So the CompanyEdit.aspx was load again with wrong id (id now is "res.aspx"). 

So, do you have any ideas to solve this problem, or other design.

Thanks, and best regard

Display homepage node along with child nodes


If the first Sitemap node is your homepage/default and all other nodes are supposed to be children / grandchildren of the first sitemap node in a web.sitemap, how do I set up my web.sitemap to enable me to display my cssFriendlyMenu with the homepage node along with the nodes that are 1 level down from it at the same time as in :

Home   Products   Services   About us


...or is it not possible to have the first sitemap node displayed along with the nodes that are 1 level down from it?  Do I need to have a different starting node rather than my homepage node?

XML Schemas: Take Advantage of Existing External XML Schemas with a Custom Import Framework in ASP.N


Over the years, many industry-standard XML schemas and dialects have been developed. These industry-specific schemas embrace the original purpose of XML and are extremely valuable in promoting and supporting B2B interaction. Unfortunately, the ASP.NET Web Services runtime does not allow developers to directly reference external schemas from within their XML Web Services interface (the WSDL file). This article builds an external schema framework as an extension to the ASP.NET Web Services runtime to enable you to reference external schemas within your XML Web Service interface.

Scott Short

MSDN Magazine December 2002

ImageURL SiteMap Node


Hi Can anyone tell me how i can add the ImageURL from a sitemap into a navigation menu, i had this working with webforms but cannot get it to work with mcv

var sbMenuHelper = new StringBuilder();

sbMenuHelper.Append("<ul class='cssMenu'>");

var topLevelNodes = SiteMap.RootNode.ChildNodes;
foreach (SiteMapNode node in topLevelNodes)
    if (SiteMap.CurrentNode == node)
        sbMenuHelper.AppendFormat("<a href='{0}'>{1}</a>", node.Url, helper.Encode(node.Title));

return sbMenuHelper.ToString();

        description="Contact Us"

Error message when selecting a row in webdatagrid



I have a webdatagrid control that is loaded by using an sqldatasource.  I have add and edit methods that behave correctly, however, I have a problem when I delete a row.   I can delete the row correctly from the datagrid and the database, but as soon as I select another row in the grid straight after, I get an error:

Microsoft JScript runtime error: 'undefined' is null or not an object


There are no events wired up to the row select, so it doesn't appear to be that.


Can anyone help?


Connect to existing sql 2005 database


Hello There,

I had successfully restored sql 2000 database to sql 2005. It works like charm

Now i am creating a database model in MVC

I follow these steps

Right click on model > ADO.NET entity data model > Generate from database > New connection (Microsoft sql server) > server name > select or enter database name

But no server name AND database name show in both drop down lists. When i mannually enter database name (which exists in sql 2005) then click on TEST CONNECTION. It gives follwoing error

"A network-related or instance-specific error while establishing a connection to sql server. the server was not found or was not accessible. verify that the instance name is correct and that sql server is configured to allow remote connections.

Kindly help me with this


Help needed in selecting coulmns from 2 tables using entity framework


Hi all,

I have two tabels as mentioned below. I am using entity framework and vs2010.I am not able to write linq query to get data from both the tables. there is one to many relationship(for one category ther can be multiple articles). Please help me out as this is very urgent. Thanks in advance.

1) Article

ArticleID bigint Unchecked
CategoryID int Unchecked
ArticleName varchar(500) Unchecked
ArticleDesc nchar(1024) Unchecked
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend