Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > problem with postback

Reply
Thread Tools

problem with postback

 
 
David
Guest
Posts: n/a
 
      12-17-2007
Hi,

I have a problem with postback. When the page is postbacked, i want the
second dropdownlist to be visible if the selectedvalue of the first one
="y".
With this code, it remains invisible. What do i wrong here?
Thanks
David

<aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
<asp:ListItem>x</asp:ListItem>
<asp:ListItem>y</asp:ListItem>
</aspropDownList>

<br /> <br />
<aspropDownList ID="DropDownList2" runat="server"
AutoPostBack=true Visible=false>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
</aspropDownList>

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
If Page.IsPostBack Then
If DropDownList1.SelectedValue = "y" Then
DropDownList2.Visible = True
End if
End If
End Sub




 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      12-17-2007
why not just put that logic in the SelectedIndexchanged event, making the
2nd ddl invisible by default.?

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup


"David" <> wrote in message
news:...
> Hi,
>
> I have a problem with postback. When the page is postbacked, i want the
> second dropdownlist to be visible if the selectedvalue of the first one
> ="y".
> With this code, it remains invisible. What do i wrong here?
> Thanks
> David
>
> <aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
> <asp:ListItem>x</asp:ListItem>
> <asp:ListItem>y</asp:ListItem>
> </aspropDownList>
>
> <br /> <br />
> <aspropDownList ID="DropDownList2" runat="server"
> AutoPostBack=true Visible=false>
> <asp:ListItem>1</asp:ListItem>
> <asp:ListItem>2</asp:ListItem>
> </aspropDownList>
>
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
> If Page.IsPostBack Then
> If DropDownList1.SelectedValue = "y" Then
> DropDownList2.Visible = True
> End if
> End If
> End Sub
>
>
>
>



 
Reply With Quote
 
 
 
 
David
Guest
Posts: n/a
 
      12-17-2007
Thanks for replying.
I tried the code within this:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
....
End Sub

but ddl2 still invisible.
I don't understand why the Page.IsPostBack doesn't work ...


"David Wier" <> schreef in bericht
news:edEwc%...
> why not just put that logic in the SelectedIndexchanged event, making the
> 2nd ddl invisible by default.?
>
> David Wier
> http://aspnet101.com
> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
> no bloated markup
>
>
> "David" <> wrote in message
> news:...
>> Hi,
>>
>> I have a problem with postback. When the page is postbacked, i want the
>> second dropdownlist to be visible if the selectedvalue of the first one
>> ="y".
>> With this code, it remains invisible. What do i wrong here?
>> Thanks
>> David
>>
>> <aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
>> <asp:ListItem>x</asp:ListItem>
>> <asp:ListItem>y</asp:ListItem>
>> </aspropDownList>
>>
>> <br /> <br />
>> <aspropDownList ID="DropDownList2" runat="server"
>> AutoPostBack=true Visible=false>
>> <asp:ListItem>1</asp:ListItem>
>> <asp:ListItem>2</asp:ListItem>
>> </aspropDownList>
>>
>> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles Me.Load
>> If Page.IsPostBack Then
>> If DropDownList1.SelectedValue = "y" Then
>> DropDownList2.Visible = True
>> End if
>> End If
>> End Sub
>>
>>
>>
>>

>
>



 
Reply With Quote
 
David Wier
Guest
Posts: n/a
 
      12-17-2007
I just tried this:

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
If DropDownList1.SelectedValue = "y" Then DropDownList2.Visible = "True"
End Sub

and it worked fine for me

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup


"David" <> wrote in message
news:...
> Thanks for replying.
> I tried the code within this:
> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
> ...
> End Sub
>
> but ddl2 still invisible.
> I don't understand why the Page.IsPostBack doesn't work ...
>
>
> "David Wier" <> schreef in bericht
> news:edEwc%...
>> why not just put that logic in the SelectedIndexchanged event, making the
>> 2nd ddl invisible by default.?
>>
>> David Wier
>> http://aspnet101.com
>> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
>> no bloated markup
>>
>>
>> "David" <> wrote in message
>> news:...
>>> Hi,
>>>
>>> I have a problem with postback. When the page is postbacked, i want the
>>> second dropdownlist to be visible if the selectedvalue of the first one
>>> ="y".
>>> With this code, it remains invisible. What do i wrong here?
>>> Thanks
>>> David
>>>
>>> <aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
>>> <asp:ListItem>x</asp:ListItem>
>>> <asp:ListItem>y</asp:ListItem>
>>> </aspropDownList>
>>>
>>> <br /> <br />
>>> <aspropDownList ID="DropDownList2" runat="server"
>>> AutoPostBack=true Visible=false>
>>> <asp:ListItem>1</asp:ListItem>
>>> <asp:ListItem>2</asp:ListItem>
>>> </aspropDownList>
>>>
>>> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>> System.EventArgs) Handles Me.Load
>>> If Page.IsPostBack Then
>>> If DropDownList1.SelectedValue = "y" Then
>>> DropDownList2.Visible = True
>>> End if
>>> End If
>>> End Sub
>>>
>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
David
Guest
Posts: n/a
 
      12-17-2007
In order to check the AutoPostBack only, i reduced the code to this:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br /><br />
<aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true >
<asp:ListItem>x</asp:ListItem>
<asp:ListItem>y</asp:ListItem>
</aspropDownList>

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Label1.Text = "ok"
End If
End Sub

But after having chosen a value in the DDL, the label.text never becomes
"ok".

So AutoPostBack doesn't work??? Or i forget to set a parameter or an option
in web.config or ...?







"David Wier" <> schreef in bericht
news:%...
>I just tried this:
>
> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
> If DropDownList1.SelectedValue = "y" Then DropDownList2.Visible = "True"
> End Sub
>
> and it worked fine for me
>
> David Wier
> http://aspnet101.com
> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
> no bloated markup
>
>
> "David" <> wrote in message
> news:...
>> Thanks for replying.
>> I tried the code within this:
>> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
>> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
>> ...
>> End Sub
>>
>> but ddl2 still invisible.
>> I don't understand why the Page.IsPostBack doesn't work ...
>>
>>
>> "David Wier" <> schreef in bericht
>> news:edEwc%...
>>> why not just put that logic in the SelectedIndexchanged event, making
>>> the 2nd ddl invisible by default.?
>>>
>>> David Wier
>>> http://aspnet101.com
>>> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML
>>> with no bloated markup
>>>
>>>
>>> "David" <> wrote in message
>>> news:...
>>>> Hi,
>>>>
>>>> I have a problem with postback. When the page is postbacked, i want the
>>>> second dropdownlist to be visible if the selectedvalue of the first one
>>>> ="y".
>>>> With this code, it remains invisible. What do i wrong here?
>>>> Thanks
>>>> David
>>>>
>>>> <aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
>>>> <asp:ListItem>x</asp:ListItem>
>>>> <asp:ListItem>y</asp:ListItem>
>>>> </aspropDownList>
>>>>
>>>> <br /> <br />
>>>> <aspropDownList ID="DropDownList2" runat="server"
>>>> AutoPostBack=true Visible=false>
>>>> <asp:ListItem>1</asp:ListItem>
>>>> <asp:ListItem>2</asp:ListItem>
>>>> </aspropDownList>
>>>>
>>>> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles Me.Load
>>>> If Page.IsPostBack Then
>>>> If DropDownList1.SelectedValue = "y" Then
>>>> DropDownList2.Visible = True
>>>> End if
>>>> End If
>>>> End Sub
>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
David
Guest
Posts: n/a
 
      12-17-2007
I have just tested the reduced code with Cassini (included in VWD 200 and
.... it works.
But when i try it with the normal browser IE 7 (with IIS), it doesn't ...

"David Wier" <> schreef in bericht
news:%...
>I just tried this:
>
> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
> If DropDownList1.SelectedValue = "y" Then DropDownList2.Visible = "True"
> End Sub
>
> and it worked fine for me
>
> David Wier
> http://aspnet101.com
> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
> no bloated markup
>
>
> "David" <> wrote in message
> news:...
>> Thanks for replying.
>> I tried the code within this:
>> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
>> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
>> ...
>> End Sub
>>
>> but ddl2 still invisible.
>> I don't understand why the Page.IsPostBack doesn't work ...
>>
>>
>> "David Wier" <> schreef in bericht
>> news:edEwc%...
>>> why not just put that logic in the SelectedIndexchanged event, making
>>> the 2nd ddl invisible by default.?
>>>
>>> David Wier
>>> http://aspnet101.com
>>> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML
>>> with no bloated markup
>>>
>>>
>>> "David" <> wrote in message
>>> news:...
>>>> Hi,
>>>>
>>>> I have a problem with postback. When the page is postbacked, i want the
>>>> second dropdownlist to be visible if the selectedvalue of the first one
>>>> ="y".
>>>> With this code, it remains invisible. What do i wrong here?
>>>> Thanks
>>>> David
>>>>
>>>> <aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
>>>> <asp:ListItem>x</asp:ListItem>
>>>> <asp:ListItem>y</asp:ListItem>
>>>> </aspropDownList>
>>>>
>>>> <br /> <br />
>>>> <aspropDownList ID="DropDownList2" runat="server"
>>>> AutoPostBack=true Visible=false>
>>>> <asp:ListItem>1</asp:ListItem>
>>>> <asp:ListItem>2</asp:ListItem>
>>>> </aspropDownList>
>>>>
>>>> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles Me.Load
>>>> If Page.IsPostBack Then
>>>> If DropDownList1.SelectedValue = "y" Then
>>>> DropDownList2.Visible = True
>>>> End if
>>>> End If
>>>> End Sub
>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
David
Guest
Posts: n/a
 
      12-17-2007
Ok, i began it from the beginning and now it works. Strange ...
"David Wier" <> schreef in bericht
news:%...
>I just tried this:
>
> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
> If DropDownList1.SelectedValue = "y" Then DropDownList2.Visible = "True"
> End Sub
>
> and it worked fine for me
>
> David Wier
> http://aspnet101.com
> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with
> no bloated markup
>
>
> "David" <> wrote in message
> news:...
>> Thanks for replying.
>> I tried the code within this:
>> Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
>> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
>> ...
>> End Sub
>>
>> but ddl2 still invisible.
>> I don't understand why the Page.IsPostBack doesn't work ...
>>
>>
>> "David Wier" <> schreef in bericht
>> news:edEwc%...
>>> why not just put that logic in the SelectedIndexchanged event, making
>>> the 2nd ddl invisible by default.?
>>>
>>> David Wier
>>> http://aspnet101.com
>>> http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML
>>> with no bloated markup
>>>
>>>
>>> "David" <> wrote in message
>>> news:...
>>>> Hi,
>>>>
>>>> I have a problem with postback. When the page is postbacked, i want the
>>>> second dropdownlist to be visible if the selectedvalue of the first one
>>>> ="y".
>>>> With this code, it remains invisible. What do i wrong here?
>>>> Thanks
>>>> David
>>>>
>>>> <aspropDownList ID="DropDownList1" runat="server" AutoPostBack=true>
>>>> <asp:ListItem>x</asp:ListItem>
>>>> <asp:ListItem>y</asp:ListItem>
>>>> </aspropDownList>
>>>>
>>>> <br /> <br />
>>>> <aspropDownList ID="DropDownList2" runat="server"
>>>> AutoPostBack=true Visible=false>
>>>> <asp:ListItem>1</asp:ListItem>
>>>> <asp:ListItem>2</asp:ListItem>
>>>> </aspropDownList>
>>>>
>>>> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles Me.Load
>>>> If Page.IsPostBack Then
>>>> If DropDownList1.SelectedValue = "y" Then
>>>> DropDownList2.Visible = True
>>>> End if
>>>> End If
>>>> End Sub
>>>>
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using callback, I fill dorpdownlist without postback but it gets empty when a postback is executed Fabio Mastria ASP .Net 5 01-30-2008 09:07 PM
ShowDialogModal postback on close (this is not related to multiple dialogs opening upon postback) Jacky Chau ASP .Net 2 06-08-2005 05:49 PM
Can I raise a postback ? Session variable only visible after postback. Please help gce ASP .Net 2 05-08-2005 05:55 AM
Postback not being set to True on first postback =?Utf-8?B?Q2hhZA==?= ASP .Net 2 04-04-2005 06:17 PM
effecting postback without auto postback controls Psych971 ASP .Net 5 12-17-2004 08:53 PM



Advertisments