473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

c# Webform - Button.Visible=false; behaving oddly.

I have a webform in C#. This form has both a gridview and a formview. The formview displays the details of the selected gridview index. No problem there.

On the formview is a button. When this button is clicked it sends an email to the DBAs asking for a database request to be run. This works as well.

However I would like to idiot proof this webform. I would like to restrict DBA requests to only the sql that is in Code submitted, testing, or pre prod status. Code that is in Hold, Failed, or Pending DBA should not be requested.

The simplest way to do this (I guess) would be to make the button invisible if the code status is one of the three listed. Simple enough.

The problem is that the button only goes invisible once it is clicked. I would like the button to not be there at all if the TicketStatus matches one of the three.

Help?

In my codebehind I have the following (I just set it up for the "Hold" status for now to test):
Expand|Select|Wrap|Line Numbers
  1. protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         string TicketStatus = ((Label)FormView1.FindControl("F5Label")).Text;
  4.         Button EmailButton = ((Button)FormView1.FindControl("Button1"));
  5.  
  6.         if(TicketStatus.Equals("Hold"))
  7.         {
  8.             EmailButton.Visible = false;
  9.         }
  10.     }
  11.  
And the ASP portion
Expand|Select|Wrap|Line Numbers
  1. <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Request DB" />
Nov 3 '08 #1
2 3321
nateraaaa
663 Expert 512MB
You may want to try adding code that will hide your button to the OnPreRender event of the page. Just before the page loads this event will fire.

Nathan
Nov 3 '08 #2
Wow, that worked like a champ.

Thanks!
Nov 3 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: hanct | last post by:
"this" here refer to the form.. I type this.Visible=false;..but the form still can be seen! Worst still, the property editor has no Visible property to play with..why??is that a bug?? Wat the...
0
by: awightma | last post by:
Hi, I have a datagrid with a number of textboxes on it. I want one column of my table to be visible=false because it contains the id of the record from the table. For some reason when I set...
1
by: Marc Lefebvre | last post by:
Why I was unable to hide the previous button in the following code ? private void ButtonClick(Object sender, System.EventArgs e) { Button button = (Button)sender; Button previousButton =...
3
by: Adam Smith | last post by:
The following code in my onitemcreated works for some item rows in my datagrid, but not others. I am trying to set a linkbutton visible for downloading a file if the data is available in the...
2
by: kaosyeti | last post by:
i can't get this working. in vba i tried to set visible to false in an if statement that looked like this: Private Sub GroupFooter1_Format(Cancel As Integer, FormatCount As Integer) If...
1
by: walanta | last post by:
I'm trying to get rid of the TextBox1 and Button1 on the page after posted back. However, it's still visible. Any idea why? protected void Page_Load(object sender, EventArgs e) { if...
4
by: Jimmy Stewart | last post by:
I have a calculated control "ContactInfo" on my form ... ="Attn: " & In the OnCurrent event for the form I have the following code... If Me.Contact Is Null Then Me.ContactInfo.Visible = False...
1
by: pdm | last post by:
hoi access, I have a subreport and with the id of inheritance of OOP I like to reuse this subreport in other main reports and hide some fields. First, is this possible and second what is the...
4
by: thecheyenne | last post by:
Hi there everybody; Fresh from reading my Access VBA for Dummies, I'd like to update my database about activities on a school outing. Here's what I'd like to achieve. The school outing costs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.