Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

problem with postback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 17 Dec 2007 14:51 GMT
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

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

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

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
David Wier - 17 Dec 2007 15:15 GMT
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

> Hi,
>
[quoted text clipped - 25 lines]
>        End If
>    End Sub
David - 17 Dec 2007 15:32 GMT
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 ...

> why not just put that logic in the SelectedIndexchanged event, making the
> 2nd ddl invisible by default.?
[quoted text clipped - 33 lines]
>>        End If
>>    End Sub
David Wier - 17 Dec 2007 16:22 GMT
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

> Thanks for replying.
> I tried the code within this:
[quoted text clipped - 43 lines]
>>>        End If
>>>    End Sub
David - 17 Dec 2007 17:09 GMT
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 />
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack=true >
<asp:ListItem>x</asp:ListItem>
<asp:ListItem>y</asp:ListItem>
</asp:DropDownList>

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 ...?

>I just tried this:
>
[quoted text clipped - 57 lines]
>>>>        End If
>>>>    End Sub
David - 17 Dec 2007 17:14 GMT
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 ...

>I just tried this:
>
[quoted text clipped - 57 lines]
>>>>        End If
>>>>    End Sub
David - 17 Dec 2007 20:39 GMT
Ok, i began it from the beginning and now it works. Strange ...
>I just tried this:
>
[quoted text clipped - 57 lines]
>>>>        End If
>>>>    End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.