Bought a book in the Head First series about C#. The command to output text that they keep using in the book is MessageBox.show("text"). However in order to work for me I need to do Response.Write("text"). Is this because I downloaded Visual Web Developer instead of Visual Studio? The project I created is an ASP.NET Web application. So this uses a totally different syntax than what's being taught in the book? Should I just return the book?

Dani AI

Generated

Good points from , and — the root cause is a project-type mismatch, not a broken C# installation. The Head First C# examples assume a desktop-style project; an ASP.NET site runs on the server and produces HTML/JavaScript for the browser, so the UI APIs and workflows differ.

If you want to follow the book exactly, create a C# desktop project in your IDE (Windows Forms or WPF) and run the examples there. In Visual Studio the usual path is File > New > Project and pick a Visual C# Windows template; in the Express line use the C#/Desktop edition that contains desktop templates. If you only care about learning language fundamentals, a Console Application is the simplest place to try examples without UI differences getting in the way.

If you want to keep the ASP.NET project and produce client-side popups from server code, register client JavaScript from the code-behind so the browser shows the dialog. For Web Forms you can use the page client-script methods; for pages with UpdatePanel use the ScriptManager variant. Example patterns:

string js = "alert('Hello from server');";
ClientScript.RegisterStartupScript(this.GetType(), "key", js, true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "alert('Hello from server');", true);

Troubleshooting tips: confirm the project template in Solution Explorer before following a chapter, keep both web and desktop Express installs if you want both workflows, and choose book material that matches your target (ASP.NET books for web work, desktop/WPF books for GUI apps). If learning C# is the main goal, keeping the Head First book is fine — just run its exercises in the matching project type.

Recommended Answers

All 3 Replies

An ASP.NET web application does not use messageboxes. That is something for a WinForms or WCF application.

While C# is one language, there are differences in the implementation of certain procedures and other code when you compare a console vs web application. If you are interested in web development, you should buy a book for asp.net/C#.

MessageBox is not "C#" it is part of the .NET class library. Yes you need to either swap the book for an ASP.NET one, or get Visual Studio C# express. You can have both Web Developer and C# Express installed at the same time if you like, I do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.