bala3569
bala3569

Reputation: 11010

Javascript function not working after postback?

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');
}   

and

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);
}
}

and

<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>

Any suggestion???

Upvotes: 3

Views: 2333

Answers (1)

Adil
Adil

Reputation: 148120

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

Register endRequest event in javascript

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

Call your method here

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

Upvotes: 2

Related Questions