0
I have the following Dropdownlist on Asp.net Webform
<asp:DropDownList ID="DDL_Categoria" runat="server" CssClass="form-control" AppendDataBoundItems="true" >
<asp:ListItem Value="" Selected="True">Selecione</asp:ListItem>
</asp:DropDownList>
When selecting this field, automatically another Dropdownlist must be completed in the footer of the form. What is the best method? Faster, politically correct?
Method 01
Code Behind + autopostback
<asp:DropDownList ... OnSelectedIndexChanged="DDL_Categoria_SelectedIndexChanged" AutoPostBack="True"
and in code-Behind I make the logic. Disadvantage: It loads the page, if it is typing in another field may cause some delay?
Method 02:
Javascript calling in iframe. Create a new page . aspx to receive this value
<asp:DropDownList ... onchange="nome_functionJS(this.value)"
<script>
function nome_functionJS(valor){
document.getElementById("IFRAMEID").src ='monta_DDL.aspx?value=' + valor
}
Method 03: Jquery (I have no idea what to call)
With codebehind vc you can use Updatepanel with triggers to update another update panel below. With jquery, you can make the call ajax life and return a list to insert in this new combo
– Tafarel Chicotti
updatepanel I don’t like using is the ajax Component of webform right? I think it’s kind of archaic and I don’t know.. rs I think the best way is javascript because it doesn’t interfere with the form the faster it is codebehind, but a refresh on the screen, losing the focus of the user’s field, one day when the internet is not good can be very annoying.. so I wanted to know how the most experienced staff recommends.
– Dorathoto
Just the suit still from
webforms
may also be calledarcaico
and theUpdatePanel
is an ajax made specifically and prepared in a useful way for Webforms– Tafarel Chicotti
About losing focus after refresh via codebehind, there are several ways to solve the problem. For example, you can give a ". Focus()" in control. Or include "#+some-id-any" in the button or form action. That is, losing focus is no problem. In webform the problem is always the "blessed" refresh. I do not like refresh on the screen when changing a control. I would use ajax...
– Venatci