Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6866051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:07:54+00:00 2026-05-27T03:07:54+00:00

I am trying to get the message box to show the elements but messagebox

  • 0

I am trying to get the message box to show the elements but messagebox will not pop when I run the application

string xml = @"<?xml version='1.0' encoding='UTF-8'?>
<widgets>
    <widget>
        <url>~/Portal/Widgets/ServicesList.ascx</url>
        <castAs>ServicesWidget</castAs>
        <urlType>ascx</urlType>
        <parameters>
            <PortalCategoryId>3</PortalCategoryId>
        </parameters>
    </widget>
    <widget>
        <url>www.omegacoder.com</url>
        <castAs>ServicesWidget</castAs>
        <urlType>htm</urlType>
        <parameters>
            <PortalCategoryId>41</PortalCategoryId>
        </parameters>
    </widget>
</widgets>";

XDocument loaded = XDocument.Parse( xml );

var widgets = from x in loaded.Descendants( "widget" )
              select new
              {
                  URL = x.Descendants( "url" ).First().Value,
                  Category = x.Descendants( "PortalCategoryId" ).First().Value
              };

MessageBox.Show("one");
foreach ( var wd in widgets ){
MessageBox.Show("two");

 }

MessageBox.Show(“one”); shows up.
MessageBox.Show(“two”); never pops up

Also what if I wanna see a count of widgets> I am new to C#
thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:07:55+00:00Added an answer on May 27, 2026 at 3:07 am

    You can replace your LINQ query with:

    var widgets = from x in loaded.Descendants("widgets").Descendants( "widget" )
              select new
              {
                  URL = x.Descendants( "url" ).First().Value,
                  Category = x.Descendants( "PortalCategoryId" ).First().Value
              };
    

    UPDATE:
    Both versions of LINQ should work correctly. My mistake, Descendants can point not only to directly nested nodes, but to all the nodes in the subtree.

    Probable issue cause:
    However, be aware that in order to show the second message box, you have to close the first one. I’ve just tested this and it worked.

    Suggested solution:
    In order to be available to show multiple dialogs with messages, you can just create your own form class in the project, instantiate it and show it with Show() method i.e.:
    you can add a new Windows Form, call it MessageForm and use the following code:

    //MessageBox.Show(new Form(), "one");
            MessageForm msgDlg = new MessageForm() { Message = "one" };
            msgDlg.Show(this);
            foreach (var wd in widgets)
            {
                //MessageBox.Show(new Form(), "two");
                MessageForm msgDlgS = new MessageForm() { Message = "two" };
                msgDlgS.Show(this);
            }
    

    It should work as intended then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a message box to pop up in front of
Trying to get an ASP application deployed; it worked for a while but then
I am trying to get cells from excel into csharp but not sure what's
I get this message when trying to communicate with software that communicates with SOAP?
when trying to translate the confirmation message to Norwegian i get the following error:
In the following code I am trying to get the select box to display
I'm trying to get a call to EnumThreadWindows working, but I always get a
I'm trying to get all appointments in outlook in week range, but reoccurring appointments
I am trying to iterate through my xml document's nodes to get the value
I'm trying to get ghostscript to render a pdf file from a Windows box.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.