Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > ASP.NET 4.5 General Discussion
|
ASP.NET 4.5 General Discussion For ASP.NET 4.5 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2016, 04:59 PM
Registered User
 
Join Date: Apr 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Displaying messages from radio button group.

Hello,

I love the book. The first read was tough, but going through it a second time makes a world of difference.

I'm trying to make a trivia game where someone selects from a radio group an answer and when they click on a button, it posts whether or not they got it right:

Code:
protected void Queston1_Click(object sender, EventArgs e)
    {
        if(PontiacSilverdomeButton.Checked)
        {
            Response.Write("Incorrect");
        }
        else if(WayneStateButton.Checked)
        {
            Response.Write("Incorrect");
        }
        else if(DetroitButton.Checked)
        {
            Response.Write("Correct! Detroit Lions played their first game at The University of Detroit Stadium in 1934");
        }
        else if(TigersButton.Checked)
        {
            Response.Write("Incorrect");
        }
My problem is that I want to control where the message gets displayed and how do I do it? I'm not a programmer so I don't know how to display the write response to a label or validation summary? I don't seem to see it in the book or not interpreting what I read properly?

Last edited by yanni3003; April 26th, 2016 at 05:00 PM.. Reason: Forgot the code bracket
 
Old April 26th, 2016, 05:42 PM
Registered User
 
Join Date: Apr 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I solved my own question.

I switched the Response.Write("What I want to say"); into a Label.Text = "what I want to say here".
 
Old April 26th, 2016, 06:03 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yep, exactly. That would be the way to control it. as you could display the label wherever you want.

Response.Write is from the old days of classic ASP. Although it still works in .NET, there are typically better ways to generate output.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio button:the challenge is how to validate the selected radio button against the " adamolekunfemi ASP.NET 4 General Discussion 2 December 4th, 2011 09:00 PM
Group name for radio buttons in Grid view nitinp ASP.NET 2.0 Professional 0 February 27th, 2007 07:15 AM
how do I validate a radio button group whyulil ASP.NET 2.0 Basics 1 January 10th, 2007 10:44 AM
Validating group of radio buttons. rupen Javascript How-To 1 September 18th, 2006 02:44 AM
Button acts depending on radio button values janise Access 4 March 10th, 2004 12:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.