【发布时间】:2009-08-20 15:24:15
【问题描述】:
我有一个 asp.net 网络表单,有一个更新面板,其中包含一个带有文本框的表格,用户可以在其中输入值。该表位于更新面板中,因为文本框是从非常长时间运行的数据库查询中生成的。它是在表单加载几秒钟后使用计时器控件生成的。
当表单被回发时,表格对我们的代码不可用...
这是该部分的代码,这是一个动态数据编辑页面。
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel2">
<ProgressTemplate>
<div>Getting subjects...</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="2000" Enabled="false" >
</asp:Timer>
<div id="subjects_fav">
<asp:Table ID="tabSubjectsFav" runat="server" BorderWidth="2" BorderColor="Aquamarine">
</asp:Table>
</div>
<asp:Button ID="UpdateButton" runat="server" OnClick="SaveEverything" Text="Save Everything" />
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
'DynamicDataManager1.RegisterControl(DetailsView1)
DynamicDataManager1.RegisterControl(lvArticles1)
DynamicDataManager1.RegisterControl(lvArticles2)
DynamicDataManager1.RegisterControl(lvArticles3)
DynamicDataManager1.RegisterControl(lvArticles4)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
'trying to get the id_project for this page
'get article id for first article
If Not IsPostBack Then
Timer1.Enabled = True
Else
UpdatePanel2.Update()
End If
'now get related project from db
Dim db As New MTRData.mtddDataContext()
Dim art = (From a In db.articles _
Where a.id = Request.QueryString("id") Take 1 _
Select a).SingleOrDefault()
'txtid_project.Text = art.id_project
'need to use this all over the place so saving it as a property type thing as well
_ProjectID = art.id_project
_PublicationID = art.id_publication
_ArticleID = art.id
End Sub
Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If boolTimerFired = False Then
Timer1.Enabled = False
boolTimerFired = True
GenerateSubjectsFavGrid(_ArticleID)
UpdatePanel2.Update()
End If
Timer1.Enabled = False
End Sub
【问题讨论】:
标签: asp.net-ajax