HighTechTalks DotNet Forums  

problem with postback

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss problem with postback in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
David
 
Posts: n/a

Default problem with postback - 12-17-2007 , 09:51 AM






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
  #2  
Old   
David Wier
 
Posts: n/a

Default Re: problem with postback - 12-17-2007 , 10:15 AM






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" <no (AT) spam (DOT) rt> wrote

Quote:
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
  #3  
Old   
David
 
Posts: n/a

Default Re: problem with postback - 12-17-2007 , 10:32 AM



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" <dw (AT) dw (DOT) com> schreef in bericht
news:edEwc%23LQIHA.2000 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
Quote:
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" <no (AT) spam (DOT) rt> wrote in message
news:eOgxSxLQIHA.6060 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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
  #4  
Old   
David Wier
 
Posts: n/a

Default Re: problem with postback - 12-17-2007 , 11:22 AM



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" <no (AT) spam (DOT) rt> wrote

Quote:
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" <dw (AT) dw (DOT) com> schreef in bericht
news:edEwc%23LQIHA.2000 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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" <no (AT) spam (DOT) rt> wrote in message
news:eOgxSxLQIHA.6060 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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
  #5  
Old   
David
 
Posts: n/a

Default Re: problem with postback - 12-17-2007 , 12:09 PM



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" <dw (AT) dw (DOT) com> schreef in bericht
news:%23RmM4oMQIHA.4476 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Quote:
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" <no (AT) spam (DOT) rt> wrote in message
news:eVlsIIMQIHA.6036 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
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" <dw (AT) dw (DOT) com> schreef in bericht
news:edEwc%23LQIHA.2000 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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" <no (AT) spam (DOT) rt> wrote in message
news:eOgxSxLQIHA.6060 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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
  #6  
Old   
David
 
Posts: n/a

Default Re: problem with postback - 12-17-2007 , 12:14 PM



I have just tested the reduced code with Cassini (included in VWD 2008) and
.... it works.
But when i try it with the normal browser IE 7 (with IIS), it doesn't ...

"David Wier" <dw (AT) dw (DOT) com> schreef in bericht
news:%23RmM4oMQIHA.4476 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Quote:
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" <no (AT) spam (DOT) rt> wrote in message
news:eVlsIIMQIHA.6036 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
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" <dw (AT) dw (DOT) com> schreef in bericht
news:edEwc%23LQIHA.2000 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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" <no (AT) spam (DOT) rt> wrote in message
news:eOgxSxLQIHA.6060 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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
  #7  
Old   
David
 
Posts: n/a

Default Re: problem with postback - 12-17-2007 , 03:39 PM



Ok, i began it from the beginning and now it works. Strange ...
"David Wier" <dw (AT) dw (DOT) com> schreef in bericht
news:%23RmM4oMQIHA.4476 (AT) TK2MSFTNGP06 (DOT) phx.gbl...
Quote:
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" <no (AT) spam (DOT) rt> wrote in message
news:eVlsIIMQIHA.6036 (AT) TK2MSFTNGP03 (DOT) phx.gbl...
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" <dw (AT) dw (DOT) com> schreef in bericht
news:edEwc%23LQIHA.2000 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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" <no (AT) spam (DOT) rt> wrote in message
news:eOgxSxLQIHA.6060 (AT) TK2MSFTNGP05 (DOT) phx.gbl...
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 Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.