There is a page between them. The controls on the page include: two labels, buttons, dropdownlist, updatepanle, and scriptmanage, the desired function is to dynamically update the lbldrp value based on the value selected by dropdownlist.
The following is my code: aspx
The current time is: <asp: Label id = "label1" runat = "server" text = "label"> </ASP: Label>
<Asp: button id = "button1" runat = "server" text = "Update Time"/>
<Br/>
<Br/>
<Asp: dropdownlist id = "dropdownlist1" runat = "server" autopostback = "true"
Onselectedindexchanged = "dropdownlist1_selectedindexchanged">
<Asp: listitem> rabbit </ASP: listitem>
<Asp: listitem> tiger </ASP: listitem>
<Asp: listitem> monkey </ASP: listitem>
</ASP: dropdownlist>
<Asp: scriptmanager id = "scriptmanager1" runat = "server">
</ASP: scriptmanager>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Triggers>
<Asp: asyncpostbacktrigger controlid = "dropdownlist1" eventname = "selectedindexchanged"/>
</Triggers>
<Contenttemplate>
<Asp: Label id = "label2" runat = "server" text = "labe2"> </ASP: Label>
</Contenttemplate>
</ASP: updatepanel>
==================
Aspx. CS code:
Protected void page_load (Object sender, eventargs E)
{
Label1.text = datetime. Now. tostring ();
}
Protected void button2_click (Object sender, eventargs E)
{
Label2.text = datetime. Now. tostring ();
}
Protected void dropdownlistincluselectedindexchanged (Object sender, eventargs E)
{
Label2.text = dropdownlist1.selecteditem. tostring ();
}
======================== If you copy the above Code to the file separately, you will find that after you select dropdownlist, the page is not partially refreshed, in this case. add the following code to config:
<Httphandlers>
<Remove verb = "*" Path = "*. asmx"/>
<Add verb = "*" Path = "*. asmx "Validate =" false "type =" system. web. script. services. scripthandlerfactory, system. web. extensions, version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/>
<Add verb = "*" Path = "* _ appservice. axd "Validate =" false "type =" system. web. script. services. scripthandlerfactory, system. web. extensions, version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "/>
<Add verb = "Get, head" Path = "scriptresource. axd "type =" system. web. handlers. scriptresourcehandler, system. web. extensions, version = 1.0.61025.0, culture = neutral, publickeytoken = 31bf3856ad364e35 "Validate =" false "/>
</Httphandlers>
==================
If you refresh the entire page after adding it, search for the web. config: <xhtmlconformance mode = "Legacy"/> Configuration. You can delete it to achieve local refreshing, at that time, I performed partial refresh in the newly created project according to the above steps, but it was not implemented on another website by deleting the web. after <xhtmlconformance mode = "Legacy"/> in config, it is normal. I checked msdn and said that xhtmlcomformance is configured to render the control conforming to XHTML 1.0. I don't know why adding this configuration will make updatepanle unavailable.
In addition, when I checked the information on the network and said it would refresh the entire page, I should put the dropdownlist control and display in the contenttemplate. I personally think it is more convenient to put it outside, it can also be implemented. Haha. The text is not good. Sorry ..