回传后Javascript功能无法运作? [英] Javascript function not working after postback?

查看:45
本文介绍了回传后Javascript功能无法运作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我试图增加回发后iframe的高度,但是它不起作用,并且警报本身也没有弹出.这是我的代码

Here i am trying to increase the height of the iframe after postback but it is not working and the alert itself is not popping up.Here is my code

function increaseiframesize() {
alert("aaaaaa");
$('#MainContent_IFTrendAnalysis').height('523');
}   

protected void lnkBTNSubmit_Click(object sender, EventArgs e
{
TextBox txtTextBoxRetailGroup   = (TextBox)uscRetailParameters.FindControl("txtRetailCustomerGroup");
TextBox txtTextBoxPPGroup       = (TextBox)uscRetailParameters.FindControl("txtProductGroup");
if (txtTextBoxRetailGroup.Text != string.Empty && txtTextBoxPPGroup.Text != string.Empty && txtATrendStartDate.Text != string.Empty && txtATrendEndDate.Text != string.Empty)
{
this.IFTrendAnalysis.Attributes.Add("src", "");
ScriptManager.RegisterStartupScript(this, this.GetType(), "ScriptRegistration", "increaseiframesize();", true);
}
}

<asp:UpdatePanel ID="Update" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<iframe id="IFTrendAnalysis" name="IFTrendAnalysis" scrolling="auto" runat="server"
width="100%" height="403" frameborder="0"></iframe>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="imgBTNSalesTrendChart" />
<asp:AsyncPostBackTrigger ControlID="imgBTNSalesLiftChart" />
<asp:AsyncPostBackTrigger ControlID="lnkBTNSubmit" />
<asp:AsyncPostBackTrigger ControlID="imgBTNSalesLiftChart" />
<asp:AsyncPostBackTrigger ControlID="imgBTNTAEventROI" />
<asp:AsyncPostBackTrigger ControlID="imgBTNTrendAnalyzeTBL" />
</Triggers>
</asp:UpdatePanel>

任何建议?

推荐答案

我认为您正在尝试在ajax请求发送并完成并且控制权返回浏览器之后调用您的方法.应该执行形式的onload的javascript不会对ajax全部执行.如果是ajax调用,请执行此操作

I think you are trying to call your method after the ajax request is sent and completed and control get back to browser. The javascript that is supposed to execute onload of form does not execute for ajax all. If it is ajax call then do this

在javascript中注册endRequest事件

Register endRequest event in javascript

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequestHandler)

在此处调用您的方法

function EndRequestHandler(sender, args)
{
    increaseiframesize();
}

这篇关于回传后Javascript功能无法运作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆