Connecting Tech Pros Worldwide Help | Site Map

Disable control without postback

Geoff
Guest
 
Posts: n/a
#1: Nov 21 '05
Is there any way to change the enabled property of a dropdownlist without a
postback, depending on the selection in another dropdownlist?

Select Case ddlReport.SelectedValue

Case "Profit"

ddlFormat.Enabled = True

Case "Trial Balance"

ddlFormat.Enabled = False

End Select


Cor Ligthert
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Disable control without postback


Geoff,
[color=blue]
> Is there any way to change the enabled property of a dropdownlist without
> a
> postback, depending on the selection in another dropdownlist?[/color]

No

Cor


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Disable control without postback


"Cor Ligthert" <notmyfirstname@planet.nl> schrieb:[color=blue][color=green]
>> Is there any way to change the enabled property of a dropdownlist without
>> a
>> postback, depending on the selection in another dropdownlist?[/color]
>
> No[/color]

I assume that it's possible to disable another control using
JScript/VBScript without a postback, but that's slightly off-topic here.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Disable control without postback


Geoff,
It sounds like you are talking ASP.NET.

As Herfried suggests. If you want to do it server side, then you need to do
a postback. If you don't want a postback, then you will have to do it client
side with JavaScript or VBScript.

For help with client side JavaScript & VBScript you may want to ask this
"down the hall" in one of the microsoft.public.dotnet.framework.aspnet
newsgroups.

Hope this helps
Jay

"Geoff" <cbsinc@earthlink.net> wrote in message
news:6lAhd.1281$O11.93@newsread3.news.pas.earthlin k.net...[color=blue]
> Is there any way to change the enabled property of a dropdownlist without
> a
> postback, depending on the selection in another dropdownlist?
>
> Select Case ddlReport.SelectedValue
>
> Case "Profit"
>
> ddlFormat.Enabled = True
>
> Case "Trial Balance"
>
> ddlFormat.Enabled = False
>
> End Select
>
>[/color]


Cor Ligthert
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Disable control without postback


Geoff,

Although you have two answers from VBNet ASPNET experts who denies my answer
to you, my answer stays No.

This can be the information created in a webform page at client side, which
contains all information of the data in the serverside controls (from which
the dropdownlist is one) on your page.

<input type="hidden" name="__VIEWSTATE"
value="dDw5MzcwNzM4OTU7Oz6sJm5Bgc+8ub9mK/REAxFYaxmlmQ==" />

I knew lot of JavaScript, however I do not know how to change this in a way
that I could assure that the information stays consistent.

Cor



Cor Ligthert
Guest
 
Posts: n/a
#6: Nov 21 '05

re: Disable control without postback


> I knew lot of JavaScript, however I do not know how to change this in a[color=blue]
> way[/color]
I know a lot


Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#7: Nov 21 '05

re: Disable control without postback


Cor,[color=blue]
> Although you have two answers from VBNet ASPNET experts who denies my
> answer to you, my answer stays No.[/color]
That comment doesn't even warrant a response!

[color=blue]
> however I do not know how to change this in a way that I could assure that
> the information stays consistent.[/color]

You can turn off the ViewState for selected controls or all controls using
the Control.EnableViewState which DropDownList inherits.

The Page directive also has EnableViewState attribute.

Hope this helps
Jay




"Cor Ligthert" <notmyfirstname@planet.nl> wrote in message
news:e1o8$dOwEHA.3976@TK2MSFTNGP09.phx.gbl...[color=blue]
> Geoff,
>
> Although you have two answers from VBNet ASPNET experts who denies my
> answer to you, my answer stays No.
>
> This can be the information created in a webform page at client side,
> which contains all information of the data in the serverside controls
> (from which the dropdownlist is one) on your page.
>
> <input type="hidden" name="__VIEWSTATE"
> value="dDw5MzcwNzM4OTU7Oz6sJm5Bgc+8ub9mK/REAxFYaxmlmQ==" />
>
> I knew lot of JavaScript, however I do not know how to change this in a
> way that I could assure that the information stays consistent.
>
> Cor
>
>
>[/color]


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#8: Nov 21 '05

re: Disable control without postback


Addendum:
[color=blue][color=green][color=darkred]
>>> Is there any way to change the enabled property of a
>>> dropdownlist without a postback, depending on the
>>> selection in another dropdownlist?[/color]
>>
>> No[/color]
>
> I assume that it's possible to disable another control using
> JScript/VBScript without a postback, but that's slightly off-topic here.[/color]

\\\
....
<html...>
...
<head>
...
<script type="text/javascript"><![CDATA[
function disableDropdown() {
document.forms[0].elements[0].disabled = true;
}
]]></script>
</head>
<body>
<h1>Dropdown list sample</h1>
<form>
<p>
<select size="1">
<option>Item1</option>
<option>Item 2</option>
</select>
</p>
</form>
<p><a href="javascript:disableDropdown();">Disable dropdown list</a></p>
</body>
</html>
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Cor Ligthert
Guest
 
Posts: n/a
#9: Nov 21 '05

re: Disable control without postback


Jay,
[color=blue]
>You can turn off the ViewState for selected controls or all controls using
>the Control.EnableViewState which DropDownList inherits.[/color]

You are right, and have with that given the direct answer for this question.

By setting the ViewState to False it should be pretty easy for everybody who
knows a little bit of JavaScript,

So my answer becomes Yes.

:-)

Cor


Cor Ligthert
Guest
 
Posts: n/a
#10: Nov 21 '05

re: Disable control without postback


Geoff,

I was thinking a lot more in your question than there probably is, when it
is as simple as you ask is can be this a piece of JavaScript, however with
that is in my opinion still the data in the box with a postback sent back to
the server side ass well as the the selectedindex. When you want to affect
that you should do more using that viewstate enabled is false.

You can put a HTML button on your form to test it

<script language=javascript>
<!--

function Button1_onclick() {
if (document.all("DropDownList1").disabled == false) {
document.all("DropDownList1").disabled = true}
else
{
document.all("Dropdownlist1").disabled = false}
}

//-->
</script>

When you want to integrate it in VBNet you can use

Dim scriptString As String = "The script including javatags"
Page.RegisterStartupScript("Button1_OnClick", scriptString)


Cor




David
Guest
 
Posts: n/a
#11: Nov 21 '05

re: Disable control without postback


On 2004-11-02, Jay B. Harlow [MVP - Outlook] <Jay_Harlow_MVP@msn.com> wrote:[color=blue][color=green]
>> however I do not know how to change this in a way that I could assure that
>> the information stays consistent.[/color]
>
> You can turn off the ViewState for selected controls or all controls using
> the Control.EnableViewState which DropDownList inherits.
>
> The Page directive also has EnableViewState attribute.[/color]

But the user should beware that events will go wonky if you do either
of these. If you really want a dropDownList that reacts reasonably to
client-side disabling then one's best bet is to derive a class from
DropDownList and do the work yourself. You could probably achieve this
with a few very minor overrides, but I haven't looked at it in detail.

Of course, this is all probably way beyond what the original poster was
asking. On the other hand, all this is likely to bite him pretty soon.


Closed Thread