Showing posts with label master. Show all posts
Showing posts with label master. Show all posts

Saturday, March 24, 2012

My UpdatePanel does not work

Hi,

I am trying to use Updatepanel, but it does not work. The whole page is refresh it. What am doing wrong??

That is the code : (am using a master page)

<asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder2"Runat="Server">

<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true">

</asp:ScriptManager>

<tablestyle="width: 600px;"id="TABLE1"align="center">

...............................................................

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

<ContentTemplate>

<cc1:MaskedEditExtenderID="MaskedEditExtender1"TargetControlID="tbCuentaBancaria"Mask="9{4}-9{4}-9{2}-9{10}"runat="server">

</cc1:MaskedEditExtender>

<tr><tdcolspan="4">

<asp:CheckBoxID="cbCuentaBancaria"runat="server"Text="No tengo cuenta bancaria"OnCheckedChanged="cbCuentaBancaria_CheckedChanged"AutoPostBack="True"/></td></tr>

<trstyle="height: 35px;">

<tdstyle="width: 176px"><asp:LabelID="Label4"runat="server"Text="Entidad Bancaria*"Width="110px"></asp:Label></td>

<tdstyle="width: 393px"><asp:TextBoxID="tbNombreBanco"runat="server"></asp:TextBox></td>

<td><asp:LabelID="Label5"runat="server"Text="Cuenta Bancaria*"></asp:Label></td>

<td><asp:TextBoxID="tbCuentaBancaria"runat="server"></asp:TextBox></td>

</tr>

</ContentTemplate>

</asp:UpdatePanel>

..............................

</asp:Content>

To useUpdatePanel controls with master pages, you can put aScriptManager control on the master page. In this scenario, the master page provides aScriptManager control for every content page.

Check UpdateMode property of UpdatePanel, whether it is set to "Conditional" or not ?

See for more details...

http://ajax.asp.net/docs/tutorials/UsingUpdatePanelMasterPages.aspx


Thanks,

I moved the ScripManager to the Master Page but nothing happen. I have modified a little the code inside the UpdatePanel and now is working. i think it was a problems with the tr and td structure.

Naming Convention to search for a control with $get

Is there another way to find a control when using a master page and a tabContainer ?

For now I'm using the following syntax in Ajax client script:

$addHandler($get("ctl00$myContentPlaceHolder$myTabContainer$myTab1$txtPostalCode"), "keyup",mapPostalCode);

It's a little long, no ??

Thank you !

Gerrie

I usually embed the control.ClientID in a javascript variable if I need it, like so:

var txtPostalCode = "<%= txtPostalCode.ClientID %>";

Note this only works (afaik) inside on-page script tags or in an embedded .js file (from an assembly), or in a registered script block.


Great!

$addHandler($get("<%= txtPostcalCode.ClientID %>"),"keyup", mapPostalCode);

it works !!!

Thanks for this little annoying problem... sometimes little things keep me awake :-)

Navigation using Master pages and Update panel without refresh

Hi

I have a master page in which there are hyperlinks to go to different pages. Its a header basically. I got the relevant content pages for the hyperlinks.

But when I click the master page links, a postback occurs and the whole page is refreshed and directed to the new page.

I need a way by which when I click the hyperlinks in master page the content pages change without any refreshing. I heard about the Iframe implementaion in update panel is it a feasible way to do this or multiview might solve my problem ?

Having a master page sort of defeats the purpose of keeping the same page and dynamically updating portions on postback. The master page is meant to be a supplement for the page the user is viewing. This means the master page is never browsed directly, it only contains master code for each of the pages that are browsed to directly.

Also, hyperlink controls should not perform postbacks -- they are simply meant for navigation. Therefore, anytime a user clicks a hyperlink, the user will be taken to the new page, causing flicker. I suggest using a link button instead. These perform postbacks and can capture events much better than a hyperlink.

In order to do what you're trying to do, consider not using a master page. Instead, use a single page that makes use of either an iframe or a multiview enclosed in an updatepanel. Example is below:

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title>
</head>
<body>
<formid="theForm"runat="server">
<divid="wrapper">
<asp:ScriptManagerID="scriptManager"runat="server"></asp:ScriptManager>
<divid="header">
<asp:LinkButtonID="lnkClickMe"runat="server"OnClick="lnkClickMe_Click">Click Me!</asp:LinkButton>
</div>
<asp:UpdatePanelID="pnlDynamicContent"runat="server"UpdateMode="Conditional">
<ContentTemplate>
<asp:MultiViewID="mvDynamicContent"runat="server"ActiveViewIndex="0">
<asp:ViewID="viewBeforeClick"runat="server">
This is before the link above is clicked
</asp:View>
<asp:ViewID="viewAfterClick"runat="server">
This is after the link above is clicked
</asp:View>
</asp:MultiView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTriggerControlID="lnkClickMe"EventName="Click"/>
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

And the code-behind:

PartialClass Test_ForumTest
Inherits System.Web.UI.Page

ProtectedSub lnkClickMe_Click(ByVal senderAsObject,ByVal eAs EventArgs)
mvDynamicContent.ActiveViewIndex = 1
EndSub
EndClass


Convert your hyperlink to linkbuttons then register these buttons as AsyncTrigger in the Update Panel. Convert Your Content Pages to User Control. Load the Proper User Control on Button Click.

Need async post back from 1 user ctrl to another user ctrl in same master page.

Hi,

I have 3-4 web user ctrl in a Master page. Now this Master Page is being hosted by a page: ViewProductCategories.aspx. Among the userctrls on the MasterPage, I have got an ImageButton (asp:ImageButton) in one of the userctrl (ProductCtrl.ascx). Instances of ProductCtrl.ascx is being loaded dynamically on the ViewProductCategories.aspx dependng on the number of product under a category. So I have to dynamically assign the event handler for the image button click. What I want is: On the click of the asp:ImageButton (AddToCart) there should be a AsyncPostBack that only refreshes the CartCtrl.ascx which is another user ctrl on the same MasterPage, but not the other userctrls on the same master page. Situation is complex. Please let me know if any more info is needed.

Thanks,

Subhadip

Hi

You can check out this link for solution:AsyncPostBackTrigger from another user control

Please check out these linka for more information:

Trigger PostBack to an UpdatePanel from a separate UserControl?

Can I specify a UserControl custom event as a Trigger for update panel on Parent page?

Bubble Event from UserControl

Best Regards

Wednesday, March 21, 2012

need help in master pages using ajax

hi all i need an advice concerning the use of master page using async

first ive discovered that page loads using links to pages of the same master page cant be done without postback so am searching for a way to apply a way of implementing my site using master pages and ajax

so i put a master page with a header and a contant place holder next i implemented a page using mymaster page and i put within a iframe for the other pages so as those pages can be loaded asyc for the first time it seemd working just fine but when i put in the pages residing in the iframe an ajax implementation it asks for script manager so heres the prob

plz give me a good way implementing my master page without many postbacks and without using multiview

a conceptual way ........ thanks a lot

Why use masterpages if you want your pages to behave like you are using frames? You would probably be better off if you just had an aspx page with an iFrame.

Need help with MasterPages and Proxies

I watched the video, and it seemed to suggest that you only need to use proxies if you are doing ajax stuff on the master page itself? Is this true? In other words if I have a master page that just contains static stuff, do I still need to put the ScriptManager on the master page and use proxies everywhere else?

Thanks ... Ed

What you've described is the typical scenario. You don't have to use Proxies unless you've included the ScriptManager in your MasterPage. You don't have to put the ScriptManager on the MasterPage unless you need to (or just want to)...

Thanks for clearing that up.

Ed