NET: Asynchronous Refresh, DropDownList two-level linkage, Triggers

Source: Internet
Author: User

PS:: I sent a help to the forum post, incredibly no one back. So tangled ...

http://bbs.csdn.net/topics/390809330

Objective: Three DropDownList a B C, required to achieve a linkage C, B linkage C

Involved: ScriptManager. UpdatePanel, Triggers, Asyncpostbacktrigger


ScriptManager Object Set : Enable partial rendering

<asp:scriptmanager id= "ScriptManager1" runat= "Server" >
</asp:ScriptManager>

Where ScriptManager contains the attribute enablepartialrendering= "True" trueif partial rendering is enabled and full page update is forbidden; otherwise false.  The default value is true.  

in the Page_Load event, use the ScriptManager object in your page RegisterAsyncPostBackControl (Control) method. Remember that the page is stateless, so you should re-register the controls each time you create the control.

UpdatePanel

A UpdatePanel control has two child elements.

The most common element is the <ContentTemplate>   element, It essentially encapsulates the content that will be included in the update panel (that is, what we implement for partial rendering).

another element is <Triggers> That specifies the control on the page (or the user control you are using) that will trigger <Triggers> The local rendering of the UpdatePanel that the element belongs to.

Triggers

Contains each of the following two byte points and is limited in number:<asp:asyncpostbacktrigger> and <asp:PostBackTrigger>. Two common properties: ControlID and EventName, and any control can be specified in the current encapsulation unit.

The best use of the <asp:AsyncPostBackTrigger> element is that it can be used to specify events from the child controls of any UpdatePanel control in the encapsulation unit, not just the parent UpdatePanel of this trigger. Any control can trigger a partial page update.

The <asp:PostBackTrigger> element can be used to trigger a partial page rendering, but requires a full round trip to the server. This trigger element can also be used to enforce full page rendering when the control normally triggers a local page rendering when no exception is present (for example, when there is a Button control in the <ContentTemplate> element of the UpdatePanel control). Similarly, the Postbacktrigger element can specify any child controls of any UpdatePanel control in the current encapsulated cell.

Label

Description

<asp:AsyncPostBackTrigger>

Specifies a control and event that will throw a partial page update of the UpdatePanel that contains the trigger reference.

<asp:PostBackTrigger>

Specifies a control and event that will cause a full page update (the entire page refresh). This tag can be used to enforce full page rendering when a control normally triggers a local page rendering when no exception is present.


The target was: Two DropDownList trigger the list in the UpdatePanel,However, these two lists may be empty options, and do not trigger a
Now the case is, the load page, the first click of the list option will directly trigger the UpdatePanel list, then can arbitrarily change the asynchronous trigger,
at the same time, the other list does not respond to it, execute the query or Submit button, you can take all the list value
This means that any DropDownList option can be triggered, but cannot be triggered at the same time

</pre> problem code: <pre name= "code" class= "CSharp" ><asp:dropdownlist id= "Lstdepname" runat= "Server" Width= "                                        200px "autopostback=" true "onselectedindexchanged=" lstdepname_selectedindexchanged "> </asp:dropdownlist><asp:dropdownlist id= "Lstcootype" runat= "Server" width= "200px" autopostback= "true" onselectedindexchanged= "Lstcootype_selectedindexchanged" > </asp:dropdownlist&                                            Gt;<asp:updatepanel id= "UpdatePanel1" runat= "Server" childrenastriggers= "true" > <Triggers> <asp:asyncpostbacktrigger controlid= "Lstdepname "Eventname=" SelectedIndexChanged "/> <asp:asyncpostbacktrigger contr                                           Olid= "Lstcootype" eventname= "SelectedIndexChanged"/> </Triggers> <ContentTemplate> <asp:dropdownlist id= "lstcooname" runat= "server                                            "Width=" 200px > </asp:DropDownList>    </ContentTemplate> </asp:UpdatePanel>



Workaround:

I checked, triggers's eventname= "SelectedIndexChanged".

Appears to be triggered only once by the same event and can have multiple event firings,

But it seems that it can only be controlled by multiple identical events ...
Seems


If you do two-level linkage is no problem, multi-level can not be achieved

With Ajax, it would be better to implement


In summary, the problem has not been fully resolved, if you have a good explanation or solution, please reply, thank you


Resources:

Http://forums.asp.net/t/1015714.aspx

http://blog.csdn.net/StepSun/article/details/1428850

http://blog.csdn.net/qwlovedzm/article/details/6633965

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.