My code below returns the .text property of the chkEqmtRental check box but
not it's checked state. I'm creating the control in a placeholder and need
to access the check box in the codebehind. Also, is it possible to access
events for that control and if so, how?
chkEqmtRental = plh.FindControl("chkEqmtRental") 7 4335
You code below assigns the checkbox (assuming it is found) to a variable. As
Checked is a property of the checkbox, you should have no trouble accessing
it. So, you might want to explain what you're trying to say.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"tma" <tm*@allisconfusing.net> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl... My code below returns the .text property of the chkEqmtRental check box
but not it's checked state. I'm creating the control in a placeholder and need to access the check box in the codebehind. Also, is it possible to access events for that control and if so, how? chkEqmtRental = plh.FindControl("chkEqmtRental")
This what I'm trying to do:
Dim chkEqmtRental As WebControls.CheckBox
chkEqmtRental = plh.FindControl("chkEqmtRental")
If chkEqmtRental.Checked Then
....some code...
End If
Presently, the chkEqmtRental.Checked always evaluates to FALSE.
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:Ok*************@TK2MSFTNGP12.phx.gbl... You code below assigns the checkbox (assuming it is found) to a variable.
As Checked is a property of the checkbox, you should have no trouble
accessing it. So, you might want to explain what you're trying to say.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"tma" <tm*@allisconfusing.net> wrote in message news:eR**************@TK2MSFTNGP09.phx.gbl... My code below returns the .text property of the chkEqmtRental check box but not it's checked state. I'm creating the control in a placeholder and
need to access the check box in the codebehind. Also, is it possible to
access events for that control and if so, how? chkEqmtRental = plh.FindControl("chkEqmtRental")
hi tma,
I think that the problem is there because you don't cast the finded control
to a checkbox
so the code should be:
Dim chkEqmtRental as CheckBox = CType(plh.FindControl("chkEqmtRental"),
CheckBox)
chkEqmtRental.Text 'for text property
chkEqmtRental.Checked 'for checked state
what do you mean by acces the event ?
Regards
Martin
"tma" <tm*@allisconfusing.net> wrote in message
news:eR**************@TK2MSFTNGP09.phx.gbl... My code below returns the .text property of the chkEqmtRental check box
but not it's checked state. I'm creating the control in a placeholder and need to access the check box in the codebehind. Also, is it possible to access events for that control and if so, how? chkEqmtRental = plh.FindControl("chkEqmtRental")
With regard to events, I'm asking if it's possible to gain access to events
in the codebehind for controls added via placeholder.
"Martin Marinov" <me********@mecrossroad.bg> wrote in message
news:ub*************@TK2MSFTNGP11.phx.gbl... hi tma,
I think that the problem is there because you don't cast the finded
control to a checkbox so the code should be:
Dim chkEqmtRental as CheckBox = CType(plh.FindControl("chkEqmtRental"), CheckBox) chkEqmtRental.Text 'for text property chkEqmtRental.Checked 'for checked state
what do you mean by acces the event ?
Regards Martin "tma" <tm*@allisconfusing.net> wrote in message news:eR**************@TK2MSFTNGP09.phx.gbl... My code below returns the .text property of the chkEqmtRental check box but not it's checked state. I'm creating the control in a placeholder and
need to access the check box in the codebehind. Also, is it possible to
access events for that control and if so, how? chkEqmtRental = plh.FindControl("chkEqmtRental")
First, I would advise you to turn Option Strict ON. It will prevent data
type errors like this. Every Checkbox has the same properties. However, the
FindControl() method returns a type of System.Web.UI.Control, not
System.Web.UI.WebControls.CheckBox. You have to cast it as a CheckBox in
order to access the CheckBox properties.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"tma" <tm*@allisconfusing.net> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl... This what I'm trying to do:
Dim chkEqmtRental As WebControls.CheckBox
chkEqmtRental = plh.FindControl("chkEqmtRental")
If chkEqmtRental.Checked Then
...some code...
End If
Presently, the chkEqmtRental.Checked always evaluates to FALSE.
"Kevin Spencer" <ks******@takempis.com> wrote in message news:Ok*************@TK2MSFTNGP12.phx.gbl... You code below assigns the checkbox (assuming it is found) to a
variable. As Checked is a property of the checkbox, you should have no trouble accessing it. So, you might want to explain what you're trying to say.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"tma" <tm*@allisconfusing.net> wrote in message news:eR**************@TK2MSFTNGP09.phx.gbl... My code below returns the .text property of the chkEqmtRental check
box but not it's checked state. I'm creating the control in a placeholder and need to access the check box in the codebehind. Also, is it possible to access events for that control and if so, how? chkEqmtRental = plh.FindControl("chkEqmtRental")
Hi tma:
Since you mentioned using a PlaceHolder control earlier I'm thinking
you might be running into problems creating controls dynamically and
adding them to the page.
The following KB article shows how to dynamically add a control and
add an event handler: http://support.microsoft.com/default...b;EN-US;317515
Notice it also adds the control during Page_Init, which is before
Page_Load, as this can impact how the control behaves and remembers
it's state.
HTH,
--
Scott http://www.OdeToCode.com
On Mon, 9 Aug 2004 07:17:26 -0500, "tma" <tm*@allisconfusing.net>
wrote: My code below returns the .text property of the chkEqmtRental check box but not it's checked state. I'm creating the control in a placeholder and need to access the check box in the codebehind. Also, is it possible to access events for that control and if so, how? chkEqmtRental = plh.FindControl("chkEqmtRental")
With Option Strict On and the following lines, I still get no value for
..checked. I can define the chkEqmtRental as webcontrols.checkbox or just
checkbox and same result. I'm at a loss. Is anyone able to make this work?
Could you post a code sample?
table = new htmltable
cell = new htmltablecell
row = new htmltablerow
chk = New WebControls.CheckBox
chk.AutoPostBack = True
chk.Attributes.Add("runat", "server")
chk.Text = "Equipment rental"
chk.ToolTip = "Player requested rental equipment."
chk.ID = "chkEqmtRental"
cell.Controls.Add(chk)
row.Controls.Add(cell)
table.Controls.Add(row)
plh.controls.add(table)
chkEqmtRental = CType(plh.FindControl("chkEqmtRental"), CheckBox)
Cast does not return a true for .checked when box is checked.
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:ez*************@TK2MSFTNGP09.phx.gbl... First, I would advise you to turn Option Strict ON. It will prevent data type errors like this. Every Checkbox has the same properties. However,
the FindControl() method returns a type of System.Web.UI.Control, not System.Web.UI.WebControls.CheckBox. You have to cast it as a CheckBox in order to access the CheckBox properties.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"tma" <tm*@allisconfusing.net> wrote in message news:eZ**************@tk2msftngp13.phx.gbl... This what I'm trying to do:
Dim chkEqmtRental As WebControls.CheckBox
chkEqmtRental = plh.FindControl("chkEqmtRental")
If chkEqmtRental.Checked Then
...some code...
End If
Presently, the chkEqmtRental.Checked always evaluates to FALSE.
"Kevin Spencer" <ks******@takempis.com> wrote in message news:Ok*************@TK2MSFTNGP12.phx.gbl... You code below assigns the checkbox (assuming it is found) to a variable. As Checked is a property of the checkbox, you should have no trouble accessing it. So, you might want to explain what you're trying to say.
-- HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
"tma" <tm*@allisconfusing.net> wrote in message news:eR**************@TK2MSFTNGP09.phx.gbl... > My code below returns the .text property of the chkEqmtRental check box but > not it's checked state. I'm creating the control in a placeholder
and need > to access the check box in the codebehind. Also, is it possible to access > events for that control and if so, how? > chkEqmtRental = plh.FindControl("chkEqmtRental") > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: James G. Beldock |
last post by:
I have seen the following behavior: when issuing a Page.FindControl() for a
control which exists in an item template (from within an ItemDataBound()
event, for example), I get nulls back...
|
by: christof |
last post by:
How to do it:
My page:
<asp:DataList ID="dataListRoleMembers" ...>
....
<FooterTemplate>
<asp:LinkButton ID="btnAddMember" runat="server"...
|
by: encoad |
last post by:
Hi everyone,
I'm slowly going mad with Masterpages and the FindControl. After a
couple days of figuring out how to use the FindControl command from
within a Masterpage, I still can't explain...
|
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= |
last post by:
I am trying to get the text of an item in a GridView, but am doing something
wrong. Can someone help me with the correct C# statement I need? Below is my
GridView and my attempt to get the control....
|
by: daniel.hedz |
last post by:
I am generating a usercontrol dynamically successfully, but when I try
to find that usercontrol I get a type mismatch. This is what I am
doing:
//Loading my usercontrol...
|
by: Dan |
last post by:
Hi,
I created a custom control (ParentCustomControl) which is using a
custom template (implementing ITemplate interface), in the
instantiateIn method of this template I create all the controls I...
|
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= |
last post by:
Hi. I have created a UserControl ("MyUC"). I've put a bunch of instances of
that control on a Page ("Defaul.aspx"). The control works fine.
Now, I want to be able to use "FindControl()" from...
|
by: AAaron123 |
last post by:
Me.FindControl("MissionScheduleID"), below returns null.
Do you know what I'm doing wrong?
Thanks
***In my .aspx file I have:
asp:Content ID="Content3"...
|
by: Hillbilly |
last post by:
Maybe this is or isn't some kind of bug but it sure is goofy and remains a
mystery that really has me puzzled for two reasons...
// goofy syntax functions as expected...
Panel finalStepButton =...
|
by: AAaron123 |
last post by:
I'm this far in determining the correct code to find a textbox I need to
set.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
| |