ComboBox

  • Thread starter Thread starter Tamir Berger
  • Start date Start date
T

Tamir Berger

Hi,

I have an ASP.NET form that includes several combo Boxes.
The first Combo is loaded with items on Page_load.
The second depends on the item selected on the first, the third on the
second and so on.

I don't want to transfer all the data needed with the form and also want to
avoid page refresh on every item change.

What is the best method for doing this?
I heard about xmlhttp and WS but I don't know if any of those technologies
is appropriate and how to use them in the project.

Samples will help me very much.

10X.
 
If I understand you correctly, you've just ruled out the only 2
possibilities you have. Think about it. The data to populate the combo boxes
is stored on the server. Therefore, you either have to (1) pass it all to
the client to avoid having to PostBack, or (2) PostBack to get the data. If
you can think of a third way, you're probably due the Nobel Prize!

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.
 
Hello

you could also use the webservice behavior to obtain the new info and
transorm it with xsl to a <select>. or with the xmlhttp object...

other idea?



Anatoly said:
We are using a hidden iframe for this
1)Put an IFRAME with style="display:none" in this web form.
2)On combo change(client-side) write something like this:

frmServerSide.location.href =
'serverSide.aspx?Function=FillCompanyCombo&cboRegion=' +
document.frmCaseList.cboRegion.value + '&defaultCompany=' + defaultCompany;

where frmServerSide is name of IFRAME

3)in serverSide.aspx write on Page_Load() get the appropriate data (in
dataset for example) and do in loop

Response.Write("<script>")
Response.Write( " var oSelect = parent." + ComboName + "; ")
Response.Write( " var oOption; ")
//cleans the combo before filling
Response.Write( " while(oSelect.options.length>0) ")
Response.Write(" oSelect.options.remove(0);")
foreach(DataRow Row in Data.Rows){
Response.Write( " oOption = document.createElement(""OPTION"");")
Response.Write( " oOption.text = '" + Row[TextField].ToString() + "';")
Response.Write( " oOption.value = '" + Row[ValueField] + "';")
Response.Write( " oSelect.add(oOption); ")
}

ComboName is DropDownList.ClientId which you may pass from first form

HTH

Tamir Berger said:
Hi,

I have an ASP.NET form that includes several combo Boxes.
The first Combo is loaded with items on Page_load.
The second depends on the item selected on the first, the third on the
second and so on.

I don't want to transfer all the data needed with the form and also want to
avoid page refresh on every item change.

What is the best method for doing this?
I heard about xmlhttp and WS but I don't know if any of those technologies
is appropriate and how to use them in the project.

Samples will help me very much.

10X.
 
Back
Top