Showing posts with label partial. Show all posts
Showing posts with label partial. Show all posts

Saturday, March 24, 2012

Namespace for client side Postbacks

Does anybody know what the Ajax namespace for implementing a clientside (javascript) postback is? Ideally I would like to fire a partial postback event to an update panel, pass in some arguements and then capture the event in the codebehind.Did you ever find an answer to your question? I've been looking for the same thing without any success. Every example I find is all about doing things on the client side nothing about the server side using .Net AJAX.

nope. It seems that there is no direct method to call a postback from JS. I find people asking for it all over the place though, so I would hope that MS includes it in the next version.

The work around is pretty good though. You basically have two options, I use option #1.

1) Set a hidden field as a trigger. Through JavaScript, update the value of the hidden field. This causes the Ajax postback as desired.

2) I have read about people placing a "submit" button in a hidden DIV and setting that as the trigger. Again, you submit the button via JS.

Let me know if you get stuck and I can send you code.


Thanks for your reply, actually I'm trying to write a control that uses the UpdatePanel. I wrap my control in it and I've tried adding some buttons to the triggers collection, but when I click the button it performs a normal postback. Is there anything special you've found that needs to be done for something like this to cause an ajax postback? What I'm doing here sounds kind of like your second suggestion, but it doesn't seem to work.

Anything INSIDE an Update panel should cause only an "Ajax" postback, and that includes other controls. Make sure you have the attribute Updatemode set to conditional. Like so:

<

asp:UpdatePanelID="UpdatePanel1"runat="server"UpdateMode="conditional">

Wednesday, March 21, 2012

Need partial page update when IFrame is placed inside the updatepanel

How to achieve partial page update when an iFrame is placed inside the updatepanel. The page is getting posted completely. Any suggestions please tell me.

<ajax:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<iframeid="Iframe1"src="Default5.aspx"runat="server"

scrolling="no"frameborder="0"

style="width: 466px;height:100px">

</iframe>

<hr/>

<asp:LabelID="Label2"runat="server"Text="Label"></asp:Label>

<hr/>

</ContentTemplate>

<Triggers>

<ajax:AsyncPostBackTriggerControlID="Button1"EventName="Click"/>

</Triggers>

</ajax:UpdatePanel>

Hi,devingtonb

The page isn'tgetting posted completely as you said, it just refreshed theDefault5.aspx in the "Iframe1"!

Look at the following codes:

<%@. Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Label2.Text = DateTime.Now.ToString()
Label1.Text = DateTime.Now.ToString()
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<iframe id="Iframe1" src="http://pics.10026.com/?src=Default5.aspx" runat="server" scrolling="no" frameborder="0"
style="width: 466px; height: 100px"></iframe>
<hr />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<hr />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>

After the clicked the Button,The Label2.Text changed,but the Label1.Text didn't changed, so we can see that the page isn'tgetting posted completely!

Hope this helps!


Hi Jin,

But here we get the feel of the page getting posted completely. If it is a busy page like a database driven page, the page gets completely posted.

Is there any option or attributes to be set in the updatepanel to get it. In ATLAS, this does not happen this way, the page is refreshed on that IFRAME area only.

Regards,

Devington