.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

How to detect empty element closing tags in XmlTextReader?

Posted By:      Posted Date: September 22, 2010    Points: 0   Category :.NET Framework
How do I detect the closure of an element in the form of <foo  stuff.stuff.stuff   />   ?

In this (Microsoft generated) XAML fragment  . . .

<Window x:Class="WpfXml2.Window1"
    Title="Window1" Height="372.185" Width="613.272">
    <Grid Width="534.391">
        <ListBox Margin="41,66,37,11.891" Name="listBox1" FontFamily="Ariel" FontSize="12" />
        <Label Height="24.442" HorizontalAlignment="Right" Margin="0,23.331,105.545,0" Name="label1" VerticalAlignment="Top" Width="120">Label</Label>

. . .

Using MoveToElement() when I get to the start of Listbox it has a NodeType of "Element" and a Name of "Listbox"  (as I expected)  On the next MoveToElement() it shows a NodeType of "Whitespace" and IsEmpt

View Complete Post

More Related Resource Links

JPEGS with empty IPTC / APP14 Tags cause GDI+ error

I am curious as to why the GDI+ libraries error our with exc = {"A generic error occurred in GDI+."} when the IPTC headers are empty.  I would assume it should reasonably take care of this.  I have taken am image and changed the "ff ed" app14 marker to more generic "ff ec" and everything loads fine and dandy.  So by analysis I am looking at a jpg the IPTC header has no data and I am guessing the GDI+ libraries dont handle empty data very well.  Anyone else having this problem.  Only workaround which is expensive is creating a new image and saving it to the stream which in a sense basically strips the header data making it more generic of an image.   System.Drawing.Image image = Image.FromFile("c:\\test6.jpg"); System.Drawing.Image image2 = null; ImageFormat format = ImageFormat.Jpeg; using (var stream = new MemoryStream()) { try { image.Save(stream, format); //using jpg with empty IPTC data will throw GDI+ error } catch (Exception exc) { image2 = new Bitmap(image);//this is expensive but gets job done image2.Save(stream, format); } context.HttpContext.Response.BinaryWrite(stream.ToArray()); } JPG Hex Bytes from beginning of file.  The Internal of the stream will error out about 24 bytes with a lengt

how to make sure for not empty XML element?

Msg 2298, Level 16, State 1, Line 1 Attribute "use" is not valid in this schema context whats wrong below, CREATE XML SCHEMA COLLECTION TestSchema5 AS' <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Address"> <xs:complexType> <xs:sequence> <xs:element name="Name" type="xs:string" use = "required"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>'

How to insert opening and closing tags into an existing XML using C#

Hi guys, I have what seems to be an easy task to do but I cannot find a solution to it. I would like to insert an opening and a closing tag into an existing XML file using C# code. The tags of interest are shown in bold below: <AAAAA>     <XXXX text="gggg">         <BBBB>Something</BBBB>         <CCCC>Another thing</CCCC>     </XXXX> </AAAAA> Any assistance is very much appreciated. Patrice

Using trim to check element is empty in jQuery

Using trim method, one can also check element is empty or not.

for xml path output - empty tags should be

here's tha sample code:
'alpha' _name,
'alp333' _username
for xml path(''), type),
(select ccy, acc  from #samp
for xml path(''), type)
for xml path('ccyXML'),elements
current output:
    <acc />
    <acc />

How to detect and avoid memory and resources leaks in .NET application

Despite what a lot of people believe, it's easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption.

I'll explain in this article why memory leaks exist in .NET and how to avoid them. Don't worry, I won't focus here on the inner workings of the garbage collector and other advanced characteristics of memory and resources management in .NET.

UpdatePanel is not a known element - message when upgrading to 1.0 ajax


It worked on one of my old pages.  I change the web.config, renamed all the <asp.

On some aspx page it doesn't recognize the updatepanel.  It only does on one page.  If I create a new aspx page with a different name - then it works.

Should I just create a new web project ajax - then copy all my code into there?  Or is there a way to get those old pages to recognize the new ajax controls?

How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

Rendering data with HTML tags in the DD Gridview for a selected column


I am having trouble finding out where and how to HTML Encode a cell's data on the Dynamic Data (v4.0) gridview of List.aspx.  As a simple case, suppose I have formatted cell data that is A<br/>B in the DB.    Obviously, I want A stacked on B in the cell.

It seems gridView1.HtmlEncode = true has gone away.

So maybe I'll try to catch it on the RowDataBound event:

protected void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)

            if (e.Row.RowType == DataControlRowType.DataRow)
                // Html Encode the cells


but this event never fires?

Has anyone figured out how to properly render HTML tags data in the List.aspx's GridView1? 

If I figure this out, then I can add a MetaAttribute called something like [EncodeAsHtml(true)] and be on my way.  Thanks!

http/localhost is empty


I have Win , I install the following

in Internet Information Service->

Web Management Tools (check)

Application Development Features I check (.Net Extensibility, ASP.net, ISAPIExtensions, ISAPIFilterd,  I can see  IIS Manager under my Administrative tool , but when I call


I  can't see the welcome page , what is wrong

thank you!

get value from xml element



i have this xml

<Field Name="Users_wff_AU" Type="FIELD_TYPE_STRING" MultiValue="True">
<Value No="1">xyz</Value>
<Value No="2">abcl</Value>
<Value No="3">xcc</Value>

i want to get the  xcc in string variable

Dim strwfUser As String = xNode.Item("Value").InnerText

Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap



I created 2 projects in my solution:

  1. Classic asp.net web service (asmx)
  2. Class library project which references service
  3. web site project which references class library project
  4. Windows app project which references service.

Both projects were created in 3.5 framework and in Visual Studio 2008 Beta 2.

I added web service reference to Class library project. When it asked for namespace I typed "CurrencyProxy". Projects build ok, but when I run web app, Class library throws an error: Could not find default endpoint element that references contract 'CurrencyProxy.CurrencyServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

I believe it has something to do with app.config in Class library project. Here is part from app.config:

<binding name="CurrencyServiceSoap" closeTimeout=

Detect Browser Screen Size??


Hi Everyone,  I need to detect the size of the user's screen for mobile devices (especially the BlackBerry). I've read a lot of pages that seem to refer me to the Request.Browser object, but I'm finding that this object doesn't have the correct values. For example, I have a BlackBerry and when I use the Request.Browser to get the screen size, it tells me it is 640x480. Well, I know it's not that big since an image of 300px wide just barely fits. Also, when I run on my desktop browser, it also says my screen is 640x480. I can assure you, it is not 640x480! ha!

  How does anyone reliably get the browser's screen size?? Do I have to revert to some kind of JavaScript? If so, where can I read more about it? Will it be any more reliable? Someone must have an idea about this. Thanks in advance!!

How to detect mobile phone name/model no from asp.net?


Hi experts,

Can I detect the Name/model no of the mobile phones ,which are browsing my asp.net website from C# code behind? I need to show welcome message, addressing their model numbers and redirect to appropriate pages.

Thanks in advance for your reply.


Create web site specific to mobile device, how to detect?



I have a website that is written in .Net 2.0 which uses all the nice rich functionality of the web (Ajax, javascript etc..).  However I have noticed that the site does not display very well on mobile devices. 

So therefore I would like to create a more streamlined version of my site that is better tailored to these devices.  However how do detect that the user has come to the site via a mobile device and how can i redirect them to my tailored page

Many thanks in advance

How to detect Mobile devices like Pocket PC??

Hi all,
Need help on this. As you know there is PDA-phone like Pocket PC-phone run on Window Mobile 2003 and above. It has Ms Internet Explorer of scale down version.

So, the question is this kind of device is under mobile device category but having IE browser. So, how to detect this kind of MObile device using MobileCapabilities class?  YOu see, SmartPhone also have Ms IE browser. How to tell them apart?? If I serve Pda-html website to SmartPhone, its screen size will be too small for it.

My objective is this : to detect the PDA device and Mobile Phone .

If it is PocketPC-phone, I will serve PDA-html website or Mobile web base on customer selection.
If it is smartphone or WAP 2.0 -base mobile phone, I will serve  Mobile Web.

please help.

'element.className' is null or not an object



I just downloaded the project, compiled it and ran it right out of the box and when I put the mouse pointer over or remove the mouse pointer from either MenuItem in the menu demo, I generate this error:

'element.className' is null or not an object

It points to this javascript method:

updateClassName: function(operation, element, name, value) {
        this[operation + 'String'](
                function() {
                    return element.className;
                function(newValue) {
                    element.className = newValue;

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