Vx_Chemical
asked on
Load webpage from listbox Selection
I want to load a webpage from a listbox selection, my listbox is generated from a database.
any hints at what code i should use to accomplish this, iv searched around and havent found a C# answer for it.
any hints at what code i should use to accomplish this, iv searched around and havent found a C# answer for it.
sorry, cut and paste blunder: onchange="window.open(this .options[t his.select edIndex].v alue,'_top ')"
ASKER
As i wrote i would like a C# answer for it :)
But thanks anyway
The code for listbox and the database is already in order,
The values in the data base
Are:
ID: 1
Location: Here
ID: 2
Location: There
i want when i select There, to have the webpage change to There.aspx
But thanks anyway
The code for listbox and the database is already in order,
The values in the data base
Are:
ID: 1
Location: Here
ID: 2
Location: There
i want when i select There, to have the webpage change to There.aspx
set ListBox AutoPostBack="true" to true, handle OnSelectedIndexChanged, in the event handler code use Response.Redirect("") to the page you want
ASKER
ohhh i wrote listbox when i meant dropdownlist, sorry for the confusion
You would still need to set the onchange event for the listbox and the end result would be that the aspx would write out javascript to the page.
I'll see if I can find the c# property for this but the onchange text would be:
onchange="location.href=th is.options [this.sele ctedIndex] .value + '.aspx'"
I'll see if I can find the c# property for this but the onchange text would be:
onchange="location.href=th
Use OnSelectedIndexChanged event of dropdownlist.
In that event write
Response.Redirect(DropDown List1.Sele ctedItem.T ext + ".aspx") ;
In that event write
Response.Redirect(DropDown
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Coagantus
When testing the code in a secluded project it worked just as it should, however when im implmenting it into my website nothing happens, ill try and paste some of the code which im using
first my aspx.cs
protected void locationDropDown_SelectedI ndexChange d(object sender, EventArgs e)
{
Response.Redirect(location DropDown.S electedVal ue + ".aspx");
my aspx attached as cude
When testing the code in a secluded project it worked just as it should, however when im implmenting it into my website nothing happens, ill try and paste some of the code which im using
first my aspx.cs
protected void locationDropDown_SelectedI
{
Response.Redirect(location
my aspx attached as cude
<td align="left" style="width: 160px">
*
Location of Access:</td>
<td align="left" style="width: 179px">
<asp:DropDownList ID="locationDropDown" runat="server" AutoPostBack="True"
DataSourceID="locationSrc"
DataTextField="Location" DataValueField="Id" Width="155px">
</asp:DropDownList><asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToValidate="locationDropDown"
ErrorMessage="Please select location of visit" Operator="NotEqual"
ValueToCompare="5">*</asp:CompareValidator></td>
Location is in DataTextField. So try
Response.Redirect(location DropDown.S electedIte m.Text + ".aspx") ;
Response.Redirect(location
ASKER
That doesnt seem to work im afraid.
There are two options in my database, lets call them Here and There for now, one has in ID of 1 and the other of 4.
It does the Autopost back, but the page doesnt change.
There are two options in my database, lets call them Here and There for now, one has in ID of 1 and the other of 4.
It does the Autopost back, but the page doesnt change.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great work, thanks for everyone involved, im still new at this but i learn something everyday!
Somethign like onchange="window.open(this