473,800 Members | 2,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

24 New Member
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 3337
nateraaaa
663 Recognized Expert Contributor
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
somacore
24 New Member
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
1972
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 difference between Visible=false and opacity=0;??? Posted Via Usenet.com Premium Usenet Newsgroup Services
0
1458
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 visible=true on the aspx page I can access it no problem, but when I set visible=false the value that is returned is always equal to "" Dim testing8 As String = CType(e.Item.Cells(8).Controls(1),
1
3451
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 = (Button)Session; if( previousButton == null ) {
3
2102
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 database, otherwise set a "not available" label visible. The outcome is that for the first row on my datagrid, the linkbutton is visible, for the second row both the linkbutton *and* the label are visible and for the third row, again only the...
2
2829
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 IsNull(Forms!formquerybuilder.Controls!cboxdepartment) = False Then Reports!rptcontactdata.Section(GroupFooter1).Visible = False End If instead of 'groupfooter1' i tried using 'section(1)', i tried using 'saleperson footer' which is the name of the...
1
2116
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 (Page.IsPostBack == true) { TextBox1.Visible.Equals(false); Button1.Visible.Equals(false);
4
2667
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 End If The idea is, that if there is no contact listed (I have the contact field on the form with visible property set to no) then this line will not display.
1
3347
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 correct syntax. I tried many combinations but error on syntax. first I create a MainReportFeedMainReports with only one subReport where 5 fields are not visible. I need the correct syntax to say on the event Open
4
7828
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 money - nothing's for free these days. The prices for the individual activities are stored in tbl.prices; in this table, there are 3 fields: PriceID, Amount, Description and 4 records: a record for the morning activity a...
0
10505
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10035
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9090
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7580
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6813
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.