Ho questo codice, che premendo il button carica una gridview.
Vorrei che nell' attesa del caricamento venga visualizzata una figura.gif.
In teoria mi funziona, ma solo una volta.
La cosa strana � che se faccio la simulazione con un Thread, funziona sempre, ma quando lancio la routine Getdati, che mi tira su i dari, mi funziona una volta sola.
codice behind:codice HTML:<%@PageLanguage="vb"AutoEventWireup="false"CodeBehind="WebForm3.aspx.vb"Inherits="Web_Test_Spinner_Lorenzo.WebForm3"%> <!DOCTYPEhtml> <htmlxmlns="http://www.w3.org/1999/xhtml"> <headrunat="server"> <metahttp-equiv="Content-Type"content="text/html; charset=utf-8"/> <title></title> </head> <body> <formid="form1"runat="server"> <div> <asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager> <asp:UpdateProgressID="UpdateProgress"runat="server"AssociatedUpdatePanelID="UpdatePanel1"> <ProgressTemplate> Searching.... <divid="progresso"class="progress"> <imgsrc="Resources\waiting2.gif"/> please wait... </div> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="Conditional"> <ContentTemplate> <fieldset> <legend>UpdatePanel1</legend> <asp:LabelID="Label1"runat="server"Text="Panel initially rendered."></asp:Label> <br/> <asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> <asp:ListItemValue="1">Choose</asp:ListItem> <asp:ListItemValue="2">Blue</asp:ListItem> <asp:ListItemValue="3">Green</asp:ListItem> </asp:DropDownList> <br/> <asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/> </fieldset> <asp:GridViewID="GridView2"runat="server"AllowPaging="false"></asp:GridView> </ContentTemplate> <Triggers> <asp:AsyncPostBackTriggerControlID="DropDownList1"EventName="SelectedIndexChanged"/> <asp:AsyncPostBackTriggerControlID="Button1"EventName="Click"/> </Triggers> </asp:UpdatePanel> </div> </form> </body> </html>
codice:ImportsSystem.Configuration ImportsSystem.Data ImportsSystem.Data.SqlClient ImportsSystem.Threading PublicClassWebForm3 InheritsSystem.Web.UI.Page ProtectedSubPage_Load(ByVal sender AsObject, ByVal e AsSystem.EventArgs) HandlesMe.Load IfNotIsPostBackThen Else EndIf EndSub ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e AsEventArgs) System.Threading.Thread.Sleep(3000) Label1.Text = "Page refreshed at "&DateTime.Now.ToString() 'getdata() FUNZIONA SOLO UNA VOLTA EndSub ProtectedSub DropDownList1_SelectedIndexChanged(ByVal sender AsObject, ByVal e AsEventArgs) System.Threading.Thread.Sleep(3000) Label1.Text = "Page refreshed with DDL at "&DateTime.Now.ToString() EndSub PublicSubgetdata() Dimconnx = ConfigurationManager.ConnectionStrings("Connessione_Mia").ConnectionString DimstrSQLAsString = "SELECT top 10000 * FROM tbl_Mia_Tabella " Using conn AsNewSqlConnection(connx) Try UsingcmdSQLAsSqlCommand = NewSqlCommand(strSQL, conn) conn.Open() DimrstDataAsDataTable = NewDataTable() rstData.Load(cmdSQL.ExecuteReader()) GridView2.DataSource = rstData GridView2.DataBind() EndUsing CatchessAs Exception MsgBox(ess.Message) EndTry EndUsing EndSub EndClass

Rispondi quotando
