473,226 Members | 1,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Disable control without postback

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
Nov 21 '05 #1
10 7021
Geoff,
Is there any way to change the enabled property of a dropdownlist without
a
postback, depending on the selection in another dropdownlist?


No

Cor
Nov 21 '05 #2
"Cor Ligthert" <no************@planet.nl> schrieb:
Is there any way to change the enabled property of a dropdownlist without
a
postback, depending on the selection in another dropdownlist?


No


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/>

Nov 21 '05 #3
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" <cb****@earthlink.net> wrote in message
news:6l***************@newsread3.news.pas.earthlin k.net...
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

Nov 21 '05 #4
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

Nov 21 '05 #5
> I knew lot of JavaScript, however I do not know how to change this in a
way

I know a lot
Nov 21 '05 #6
Cor,
Although you have two answers from VBNet ASPNET experts who denies my
answer to you, my answer stays No. That comment doesn't even warrant a response!

however I do not know how to change this in a way that I could assure that
the information stays consistent.
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" <no************@planet.nl> wrote in message
news:e1**************@TK2MSFTNGP09.phx.gbl... 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

Nov 21 '05 #7
Addendum:
Is there any way to change the enabled property of a
dropdownlist without a postback, depending on the
selection in another dropdownlist?


No


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


\\\
....
<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/>

Nov 21 '05 #8
Jay,
You can turn off the ViewState for selected controls or all controls using
the Control.EnableViewState which DropDownList inherits.


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
Nov 21 '05 #9
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


Nov 21 '05 #10
On 2004-11-02, Jay B. Harlow [MVP - Outlook] <Ja************@msn.com> wrote:
however I do not know how to change this in a way that I could assure that
the information stays consistent.


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.


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.
Nov 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mike Hnatt | last post by:
I have code that will set a drop-down list value to "xyz" and the .Enabled property to False. However, when I do that I can no longer retrieve the value "xyz" upon postback. It is as if I set the...
1
by: Christopher D. Wiederspan | last post by:
I'm wondering if there's a way to use javascript to disable a ASP.NET web page before it starts to postback. Specifically, here's what I'm running into. I've got a webform that has an autopostback...
6
by: Al Cohen | last post by:
I'm using a LinkButton to call some code, then do a redirect. The code does some queries, sends some emails, and takes a few moments before the redirect is performed. I'd like to disable my...
6
by: GD | last post by:
Hi, I wonder how to disable the "submit" behavior of a button. What I want is to assign values to dynamically added user controls without page postback. Problem: dynamically created control can...
2
by: Fluxray | last post by:
--Background: I have a webform including a datagrid. The datagrid is using template. Its ItemTemplate is used to display a look-up-table with labels. its EditItemTemplate is used to edit a row in...
0
by: Robert Ladd | last post by:
Hi, I'm trying to disable the asp.net calendar control from a javascript function, but it doesn't disable the doPostBack. To simplify the situation, assume a page with 4 controls. A...
9
by: junlia | last post by:
Does anyone how how can we disable the auto-postback feature in asp.net page? I have to use a server side control in the page, but the auto post back feature in it causes problems for me. Please...
4
by: Arvind P Rangan | last post by:
Hi, Has anybody worked on disabling postback event of button event in webforms. As it does not have a property of autopostback how do we make it disable. I tried few article but they have...
13
by: Rich | last post by:
Hello, So I would like to disable a textbox on a vb.net form without the text getting grayed out. In vb6 I could place a textbox control on a frame control and disable the frame leaving the...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.