Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Combining two page load statements?

Is there a way to combine these two page statements into one?  Thanks!
private void Page_Load(object sender, EventArgs e)
    {
        statusCheckName.Attributes.Add("onclick", "showHide();");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "OnLoadHandler", "showHide();", true);
    }
 
  void Page_Load()
  {
      if (Page.IsPostBack)
      {
          questionsPanel.Visible = false;
          Message.Visible = true;  
          int correct = 0;
          if (q1.SelectedIndex == 2) correct++;
          if (q2.SelectedIndex == 4) correct++;
          if (q3.SelectedIndex == 2) correct++;
          if (q4.SelectedIndex == 0) correct++;
          if (q5.SelectedIndex == 5) correct++;
          if (q6.SelectedIndex == 1) correct++;
          if (q7.SelectedIndex == 2) correct++;
 
          LoadConn(correct);
      }
      else
      {
          questionsPanel.Visible = true;
          Message.Visible = false;  
      }
  }

Open in new window

0
jianxin9
Asked:
jianxin9
  • 2
1 Solution
 
moseackCommented:
Sure:
private void Page_Load(object sender, EventArgs e)
{
	statusCheckName.Attributes.Add("onclick", "showHide();");
	Page.ClientScript.RegisterStartupScript(this.GetType(), "OnLoadHandler", "showHide();", true);
 
	if (Page.IsPostBack)
	{
		questionsPanel.Visible = false;
		Message.Visible = true;  
		int correct = 0;
		if (q1.SelectedIndex == 2) correct++;
		if (q2.SelectedIndex == 4) correct++;
		if (q3.SelectedIndex == 2) correct++;
		if (q4.SelectedIndex == 0) correct++;
		if (q5.SelectedIndex == 5) correct++;
		if (q6.SelectedIndex == 1) correct++;
		if (q7.SelectedIndex == 2) correct++;
 
		LoadConn(correct);
	}
	else
	{
		questionsPanel.Visible = true;
		Message.Visible = false;  
	}
}

Open in new window

0
 
jianxin9Author Commented:
SWEET! Thank you!!!!!!
0
 
jianxin9Author Commented:
THANK YOU!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now