Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 30th, 2007, 02:50 PM
Registered User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default masterpages, contentplaceholder, formview, button

Since I am using master pages, I have a button in a formview in a contentplaceholder. I want the visibility of the button false if the value of a textbox in the same formview is not "AO" . Which event do I handle this? I tried every event available for the formview. Here is my code.

Dim ct As ContentPlaceHolder = CType(Master.FindControl("contentplaceholder1"), ContentPlaceHolder)
Dim fv1 As FormView = CType(ct.FindControl("formview1"), FormView)
Dim tbfund As TextBox = CType(fv1.FindControl("fundTextBox"), TextBox)
Dim btn2 As Button = CType(fv1.FindControl("button2"), Button)
If Not tbfund.Text = "AO" Then
btn2.Visible = False
End If


 
Old November 30th, 2007, 03:59 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Is this something you want to have happen on the client or the server?

As you type into a textbox some client side events fire (keydown, keypress, keyup, maybe more). After you exit the textbox (if the text has changed) the client side textChanged event fires. This is the client side event that is tied to a postback when the control is set for AutoPostback so you'll only get a server side TextChanged event on a text box when the user exits the textbox. If you want to have some dynamic action take place based on a changing value of a textbox you'll need to do some client side scripting.

-Peter
 
Old December 1st, 2007, 12:35 PM
Registered User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter,
On the page is a gridview and a formview at the bottom. the formview shows a selected item from the grid. The formview only shows in edit mode. I need for a button, which goes and gets a new Travel Authorication number, to be visible=false if
1. NOT fundtextbox.text ="AO" OR
2. TATextbox.text is not null.
So, when the formview loads, on which event do I run the above logic to make the button visible or invisible? all these controls and button are inside a formview which is inside a contentplaceholder
thanks
Milton

 
Old December 1st, 2007, 09:39 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Will the values driving these conditions be changed by the user between postbacks? As I described before this will have a significant influence on the solution.

-Peter
 
Old December 2nd, 2007, 09:07 PM
Registered User
 
Join Date: Dec 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by planoie
 Will the values driving these conditions be changed by the user between postbacks? As I described before this will have a significant influence on the solution.

-Peter
NO. These values are already there. If the fund is already "AO" and the TA(Travel Authorization) textbox is empty, then the button can show, IE be visible so the user can click the button and generate a new TA. That is all I want to happen. display the Get TA button or hide the Get TA button.

 
Old December 4th, 2007, 01:17 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

I'm not sure what the problem is. Your code looks ok. However, it seems like there is a lot more than needs to be there. Why all the "FindControl" calls? The button and text box on the form should be directly accessible by their instance names.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about masterpages Kjella BOOK: Professional ASP.NET 2.0 Design: CSS, Themes, and Master Pages ISBN: 978-0-470-12448-2 3 November 29th, 2007 11:42 AM
To access a button from a formview coolvivek33 ASP.NET 2.0 Professional 0 July 11th, 2007 01:29 AM
error in source while using masterpages dotnetuser ASP.NET 2.0 Basics 4 June 28th, 2007 08:10 AM
Problems with MasterPages gobotsoup ASP.NET 2.0 Basics 2 March 7th, 2007 11:48 AM
MasterPages Help! polonskyg ASP.NET 2.0 Basics 1 March 24th, 2006 12:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.