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

  • SEARCH
  • Home
  • 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 9197181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:01:00+00:00 2026-06-17T22:01:00+00:00

Hallo i have a school task to build a game called The Hang Men

  • 0

Hallo i have a school task to build a game called “The Hang Men” ,
i started to build this game but there is one big issue that i cant Solve it

every time that i click on the button. all the elements disappear from the page.
i know the reason for that, its becase of the postback.

but if i disable from the button the postback , no thing happens.

any ideas how can i go it?
how can i click a button and do some event without creating a postback?

this is the code..

abc ltr;

Words word = null;

static Label [] lbl = null;

static Button[] btn = null;

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        SetBord();
        SetWords();
    }

}

private void SetWords()
{
    word = new Words();
    Random ids = new Random();
    string temp_word;
    int id = ids.Next(0, word.GetListSize());
    temp_word = word.GetWords(id);

    lbl = new Label[word.GetWordLenght(id)];

    for (int i = 0; i < word.GetWordLenght(id); i++)
    {
        lbl[i] = new Label();
        lbl[i].ID ="lbl"+i;
        lbl[i].CssClass = "LetterStyle";
        lbl[i].Text = Convert.ToString(word.get_chars(id,i));
        this.Words_Panel.Controls.Add(lbl[i]);
    }


}
private void SetBord()
{
    ltr = new abc();

    btn = new Button[27];
    for (int i = 0; i<27; i++)
    {
      btn[i] = new Button();  
      btn[i].ID = "btn" + i;
      btn[i].Attributes.Add("runat", "server");
      btn[i].Click += new EventHandler(LetterClicked);
      btn[i].Width = new Unit("100px");
      btn[i].Height = new Unit("49px");
      btn[i].Text = "" + ltr.getLetters(i); 
      this.Letters.Controls.Add(btn[i]);
    }


}

protected void LetterClicked(object sender, EventArgs e)
{
    Button letter = (Button)sender;
    letter.Enabled = false;
    lbl[0].Text = letter.Text;
}   
  • 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-06-17T22:01:00+00:00Added an answer on June 17, 2026 at 10:01 pm

    What you have encountered is a phenomenon when you do dynamic control creation. Since you are creating the buttons & labels dynamically in the code, these controls are not “persisted” (remembered) when you your page reloads (they are lost each time the page is reloaded/post-back).

    If there is no other way to go about the problem other than dynamically generating them; then you will have to do it like how everyone handles dynamic control creation.

    Here’s some pointers:

    • When you create a control, you need to “remember” the controls that you create (viewstate? session?).
    • When a page reload/refresh, at the Page_Load event, you will need to recreate all those controls before you can process them. This is especially true if you want to subsequently process events/values from those controls. If they are not recreated, whatever values you set on them will not be “persisted” by IIS (because IIS cannot find the controls, so the submitted values are discarded).

    You will need to structure your design/program for the above. Good luck!

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

Sidebar

Related Questions

Hallo I have this script: <? require(lib2/config.inc.php); require(lib2/tpl.class.php); require(lib2/db.class.php); require(lib2/um.class.php); $tpl = new template(templates,
hallo all i have a site which has a very big scroll on it,
Hallo, I have read Easy object binding to Treeview Node , but still have
Hallo all, i have this SQL SELECT DATE_ADD( '2009-'+ MONTH( NOW() ) +'-01' ,
This is my first post, so first hallo all. I have a little problem
Hallo I'm new to Rails and have one simple question. I'm using radiant as
i have a java beginner question: Parent.print() prints hallo in the console, but also
Hallo, I have a quite strange problem in one of my C++ projects: I
Hallo, I'm using CMake as build system in one of my projects which is
just started learning Assembler in school, and want to ask how to compile this

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.