2
I intend to create a small web game where the user will make the decision of the characters at runtime. At the moment I have the following screen:
When the user clicks on the left button, for example, he would like a label to be created below the left button, along with 2 buttons A and B setting also a block of code on click to the A button, and another to the B button. Visually, after clicking on the left button, would look this way:
Code C# I have at the moment:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ProjetoG1
{
public partial class Padrao : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Seja bem vindo(a) ao futuro game!" + "<br>");
}
protected void btnEsquerda_Click(object sender, EventArgs e)
{
Response.Write("Você escolheu o botão esquerdo, então irá terá que escolhe entre os botões A e B");
/* Aqui é onde quero criar o botão A e B, incluindo o código onclick que será executado quando esses botões
Forem clicados */
}
protected void btnDireita_Click(object sender, EventArgs e)
{
Response.Write("Você escolheu o botão direito, então irá terá que escolhe entre os botões C e D");
/* Aqui é onde quero criar o botão C e D, incluindo o código onclick que será executado quando esses botões
Forem clicados */
}
}
}
HTML code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Padrao.aspx.cs" Inherits="ProjetoG1.Padrao" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Teste de interação com o usuário. Escolhe o botão da esquerda ou direita para continuar. A história seguirá rumos diferentes em cada um dos botões.<br />
</div>
<asp:Button ID="btnEsquerda" runat="server" OnClick="btnEsquerda_Click" Text="Esquerda" />
<asp:Button ID="btnDireita" runat="server" OnClick="btnDireita_Click" Text="Direita" Width="93px" />
</form>
</body>
</html>
How could I encode that?
The first part worked. Clicking on the left was created the button A and button B. Set the following code to the button A: Response.Write("You Chose the button A"); But when I click on it, instead of printing it below the buttons/Boxes, it disappears with the button A and B.
– antunesleo_
Response.Write
, this is using in Console application...– Marco Souza
for some reason the page is not going to the event on click of the Buta and executing the code inside it, by simply clicking the button A and B disappears.
– antunesleo_
I tried to change the text of the lblmsg inside the Uta click but when clicking the A button it hid the same way
– antunesleo_
btC had the same id as Buta I made a change in response.
– Marco Souza
The A, B, C, D buttons all keep disappearing when I click on them.
– antunesleo_
yes, they are not created again.... ideally you create a method and put the buttons there is only flame inside each event you click.
– Marco Souza