我有一个javascript方法,我必须在页面加载时从aspx页面调用.
我有一个页面,其中包含更新面板中的listview控件的一部分.当在列表视图中单击按钮时,我修改了一些数据并调用this.databind来刷新数据.即使控件位于更新面板内,看起来页面加载事件仍在触发.我想知道为什么页面加载事件被触发?是因为在listview_onitemcommand事件上调用this.databind?
updateprogress不会显示gif.如果下拉列表位于updatepanel内,没有触发器,则可以正常工作.任何的想法?
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="UpdatePanel1" runat="server" DisplayAfter="0">
<ProgressTemplate>
<div id="IMGDIV" align="center" valign="middle" runat="server" style="position: absolute;left: 52%;top: 61%;visibility:visible;vertical-align:middle; background-color:Transparent">
<img src="../App_Themes/Default/images/27-1.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:Chartlet ID="Chartlet1" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="selectedindexchanged" />
</Triggers>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud) 我在UpdatePanel中有一些元素可能会或可能会显示,具体取决于各种条件.
<asp:UpdatePanel ID="MyUpdatePanel" runat="server">
<ContentTemplate>
<asp:Panel ID="MyPanel" runat="server">
<img id="clickableImage" src="/path/to/image.png" alt="Clickable Image" />
<span id="specialMessage">You clicked on the image!</span>
<asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)
我正在尝试连接它,以便在使用以下单击clickableImage IMG时显示specialMessage SPAN:
$(document).ready(function() {
$("#clickableImage").click(function() {
$("#specialMessage").show();
});
$("#specialMessage").draggable();
});
Run Code Online (Sandbox Code Playgroud)
但是,由于MyPanel在页面加载时通常不可见(但稍后可能会根据用户交互显示),因此事件不会被连接起来.有没有办法可以挂钩这些事件,即使MyPanel在初始页面加载时不可见?
我正在构建一个asp.net cutom控件,里面有两个下拉列表:companyIdSelection和productFamilySelection.I在Page_Load填充companyIdSelection,并根据companyIdSelection中的选定项填充productFamilySelection.我使用UpdatePanels来实现这一点,但由于某种原因每次我更新companyIdSelection Page_Load被调用(据我所知,只有在重新加载整个页面时才会发生),该列表将再次重新加载并且用户选择的项目将丢失(所选项目永远是最顶尖的.)这是代码
<asp:UpdatePanel ID="updateFamilies"
runat="server"
UpdateMode="Always">
<ContentTemplate>
Company ID:<br>
<br></br>
<asp:DropDownList ID="companyIdSelection"
runat="server"
AutoPostBack="True"
OnSelectedIndexChanged="companyIdSelection_SelectedIndexChanged">
</asp:DropDownList>
<br></br>
Product Family:
<br></br>
<asp:DropDownList ID="productFamilySelection" runat="server"
AutoPostBack="True"
onselectedindexchanged="productFamilySelection_SelectedIndexChanged">
</asp:DropDownList>
<br>
</ContentTemplate>
</asp:UpdatePanel>
protected void Page_Load(object sender, EventArgs e)
{
this.companyIdSelection.DataSource = companyIds(); //companyIds returns the object containing the initial data items
this.companyIdSelection.DataBind();
}
protected void companyIdSelection_SelectedIndexChanged(object sender, EventArgs e)
{
// Page_Load is called again for some reason before this method is called, so it
// resets the companyIdSelection
EngDbService s = …Run Code Online (Sandbox Code Playgroud) 这对我的WebApplication来说并不常见,但是用户可以在UpdatePanel中加载非常长的进程.
他会等待它通过UpdateProcessing来加载.
问题是因为更新面板在一段时间后中止加载并完全破坏Web应用程序.
我怎样才能冷静这个Ajax控件呢?
offtopic:当我甚至没有修复 他们的ComboBox的麻烦时,另一个ajax麻烦
我有我想在我的网站上使用的UpdatePanel.基本上,这个想法是用户点击链接并在服务器上启动将更改数据库的服务.
所以我想写的是一个方法,如果更新数据库将返回true或false.该方法应按时间间隔运行.如果数据库已更新,它将返回true,并应触发UpdatePanel更新.
我知道你可以通过控件添加触发器.但是也可以通过代码这样做吗?这个想法是,如果用户在开始操作后停留在页面上,他将在方法返回true时看到结果.如果用户离开页面,他当然什么也看不见.
如果这不是使用它的权利,请说出来.
任何评论将不胜感激!亲切的问候,Floris
我有一个问题,ASP.NET按两次单击按钮.该按钮位于UpdatePanel内,但是当我点击它时,我得到两个回发,然后是两次按钮点击,然后两次调用我的DAL(按此顺序).我之前从未遇到过这种情况,将AutoEventWireup更改为false无效.我能想到的唯一解决方法是隐藏Web服务中的功能并使用jQuery处理复杂问题,我不想为一个小项目做些事情.
萤火虫转储在下面(这些都发生在一次点击).

我有一个动态创建的JavaScript块,该块在页面加载时执行。JS位于UpdatePanel中。
更新UpdatePanel后,我需要更新动态创建的JavaScript。一切正常,当我查看页面的生成源时,可以看到更新的JS。
我的问题是页面更新后,我需要手动重新执行JavaScript函数(因为通常在页面加载时会自动执行)。
我尝试了多种方法:
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);
function pageLoaded(sender, args) {
var updatedPanels = args.get_panelsUpdated();
// check if Main Panel was updated
for (idx = 0; idx < updatedPanels.length; idx++) {
if (updatedPanels[idx].id == "PageContent_TabContent_UpdatePanel1") {
drawVisualization();
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
要么:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(handleEndRequest);
function handleEndRequest(sender, args) {
drawVisualization();
}
Run Code Online (Sandbox Code Playgroud)
但是上述两种方法都只执行旧版本的JavaScript,根据生成的源代码,旧版本的JavaScript已更改。
是否有我所缺少的东西,或者我可以尝试其他方法?
更新:
使用@Mehdi Maujood的评论,我提出了一个可行的解决方案:
function handleEndRequest(sender, args)
{
var updatedPanels = args.get_panelsUpdated();
for (idx = 0; idx < updatedPanels.length; idx++) {
if (updatedPanels[idx].id == "PageContent_TabContent_UpdatePanel1") {
var scripts = updatedPanels[idx].getElementsByTagName('script');
for(var i=0;i<scripts.length;i++) …Run Code Online (Sandbox Code Playgroud) 我有一个关闭模态的功能:
function closeModal(name) {
$(name).modal('hide');
}
Run Code Online (Sandbox Code Playgroud)
但是,我的页面还有一个更新面板,我需要触发它.
我试着__doPostBack('UpdatePanel1', '')没有运气.
谢谢
问题是这样的:
$(document).ready(function () {
createAutoClosingAlert('.success_alert', 6000);
if(<%# IsAPostBack() %>){
if(window.parent != null){
window.parent.closeEditModal();
window.parent.closeCalendarModal();
window.parent.closeModal('#projectModal');
window.parent.closeModal('#scheduleModal');
}
}
});
Run Code Online (Sandbox Code Playgroud)
我从父母那里调用它,所以我无法获取隐藏的ID.
updatepanel ×10
asp.net ×8
c# ×4
ajax ×3
asp.net-ajax ×3
javascript ×3
.net ×2
background ×1
jquery ×1
listview ×1
postback ×1