Thursday, March 29, 2012
Set Button : autopostback to be false
?
How can I change it to be false ?
I tried this...
<td><asp:Button id="cmd1" ... autopostback="false"/></td>
But it failed. Why?
ThxThat's what you get when you use a server-side control - when it's clicked
it will post back to the server. If you don't want a postback then simply
use a <input type=button>.
-Brock
DevelopMentor
http://staff.develop.com/ballen
> The standard button is set its autopostback property to be true, am I
> right
> ?
> How can I change it to be false ?
> I tried this...
> <td><asp:Button id="cmd1" ... autopostback="false"/></td>
> But it failed. Why?
> Thx
>
Set Button : autopostback to be false
?
How can I change it to be false ?
I tried this...
<td><asp:Button id="cmd1" ... autopostback="false"/></td>
But it failed. Why?
ThxThat's what you get when you use a server-side control - when it's clicked
it will post back to the server. If you don't want a postback then simply
use a <input type=button>.
-Brock
DevelopMentor
http://staff.develop.com/ballen
> The standard button is set its autopostback property to be true, am I
> right
> ?
> How can I change it to be false ?
> I tried this...
> <td><asp:Button id="cmd1" ... autopostback="false"/></td>
> But it failed. Why?
> Thx
Set datagrid cell enabled to false
Here is my code that I tried:Dim cn As New OleDb.OleDbConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;" _
& "Persist Security Info=False;" _
& "Initial Catalog=fuel info;" _
& "UID=;PWD=;" _
& "Data Source=Server7")
cn.Open()
Dim datAdapt As New OleDb.OleDbDataAdapter("Select Vendor_No as [Vendor No], " & _
"Vendor_Name as [Vendor Name], Vendor_Terminal as [Vendor Terminal], " & _
"Vendor_Trmnl_No As [Terminal No], Vendor_City As [City], Vendor_State As " & _
"[State], ID From Other_Vendors Order By Vendor_Name", cn)
Dim datSet As New Data.DataSet
datAdapt.Fill(datSet, "Other_Vendors")
DataGrid1.DataSource = datSet
DataGrid1.DataKeyField = "ID"
DataGrid1.EditItemIndex = e.Item.ItemIndex
e.Item.Cells(3).Enabled = False
DataGrid1.DataBind()
cn.Close()
cn.Dispose()
datAdapt.Dispose()
datSet.Dispose()
As you can see, the line that is not working is "e.item.cells(3).enabled = false"
Also, if anyone knows how to set the width of the cell on the fly as well, I would appreciate that as well.
ThanksTry looking into the ItemDataBound sub and adding
e.Item.Cells(3).Enabled = False
in there. You cant disable the cells before the data is in them. RIght now you are trying to disable that cell before the data has been bound to the grid.
Jerel
Phelnglai, that did the trick. One more quick question. Could you set the cell width from the same place? If so, do you know the syntax? Thanks.
What about the cell header? What would the syntax be for that?
Thanks again!
Nevermind, I see that if you just increase the width of the actual datagrid, the fields will increase and adjust on their own at run time.
Glad you got it. Sorry I never answered your second question. I was in a car wreck and am just now getting back to work and doing thinks.
If you have any other questions, feel free to ask.
Jerel
Monday, March 26, 2012
Set Enabled to false for multiple web controls
I have a usercontrol which contains multiple server controls like
textbox, radiobutton..., I have a public field in the usercontrol
"Enabled". What i want to do is when the usercontrol's "Enabled" is
set to false, set all its child controls "Enabled" to false. I know i
can set them one by one. But there should be a easy way to do it
like :
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
}
Anyone can give me a hint?
ElaineOn May 23, 9:01 pm, elaine <elain...@.gmail.com> wrote:
> But there should be a easy way to do it
> like :
> for(int i=0;i<myUserControl.Controls.Count;i++)
> {
> control oControl = (control) myUserControl.Controls(i);
> oControl.Enabled = false;
> }
> Anyone can give me a hint?
Sorry, I'm not clear on your question...
..do you mean that the for loop you wrote up there doesn't work ?
If it does, that seems fairly simple to me.. maybe I'd try to save a
line with:
foreach(Control ctrl in this.Controls)
ctrl.Enabled=false;
However, I don't think that the base Control class defines an Enabled
property, and that might be a problem. Then again, a Control might be
a label, a text literal, a generic html control, a bunch of things
were it's not quite clear what it means to be 'enabled' or not. Maybe
when 'enabled' is turned to false on your user control, you just don't
want to display any of its children controls ?
If so, at render time, you could check the value of the user control's
Enabled property:
if(this.Enabled)
base.Render(writer);
HTH,
~O
You could use control tree recursion to touch all the controls in the way
you describe.
Here are the details:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"elaine" <elain.sun@.gmail.com> wrote in message
news:1179968508.834610.110610@.n15g2000prd.googlegroups.com...
> Hi,
> I have a usercontrol which contains multiple server controls like
> textbox, radiobutton..., I have a public field in the usercontrol
> "Enabled". What i want to do is when the usercontrol's "Enabled" is
> set to false, set all its child controls "Enabled" to false. I know i
> can set them one by one. But there should be a easy way to do it
> like :
> for(int i=0;i<myUserControl.Controls.Count;i++)
> {
> control oControl = (control) myUserControl.Controls(i);
> oControl.Enabled = false;
> }
> Anyone can give me a hint?
> Elaine
>
Set Enabled to false for multiple web controls
I have a usercontrol which contains multiple server controls like
textbox, radiobutton..., I have a public field in the usercontrol
"Enabled". What i want to do is when the usercontrol's "Enabled" is
set to false, set all its child controls "Enabled" to false. I know i
can set them one by one. But there should be a easy way to do it
like :
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
}
Anyone can give me a hint?
ElaineOn May 23, 9:01 pm, elaine <elain...@.gmail.comwrote:
Quote:
Originally Posted by
But there should be a easy way to do it
like :
>
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
>
}
>
Anyone can give me a hint?
Sorry, I'm not clear on your question...
...do you mean that the for loop you wrote up there doesn't work ?
If it does, that seems fairly simple to me.. maybe I'd try to save a
line with:
foreach(Control ctrl in this.Controls)
ctrl.Enabled=false;
However, I don't think that the base Control class defines an Enabled
property, and that might be a problem. Then again, a Control might be
a label, a text literal, a generic html control, a bunch of things
were it's not quite clear what it means to be 'enabled' or not. Maybe
when 'enabled' is turned to false on your user control, you just don't
want to display any of its children controls ?
If so, at render time, you could check the value of the user control's
Enabled property:
if(this.Enabled)
base.Render(writer);
HTH,
~O
You could use control tree recursion to touch all the controls in the way
you describe.
Here are the details:
http://SteveOrr.net/faq/ControlTreeRecursion.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"elaine" <elain.sun@.gmail.comwrote in message
news:1179968508.834610.110610@.n15g2000prd.googlegr oups.com...
Quote:
Originally Posted by
Hi,
>
I have a usercontrol which contains multiple server controls like
textbox, radiobutton..., I have a public field in the usercontrol
"Enabled". What i want to do is when the usercontrol's "Enabled" is
set to false, set all its child controls "Enabled" to false. I know i
can set them one by one. But there should be a easy way to do it
like :
>
for(int i=0;i<myUserControl.Controls.Count;i++)
{
control oControl = (control) myUserControl.Controls(i);
oControl.Enabled = false;
}
>
Anyone can give me a hint?
>
Elaine
>