Showing posts with label everybody. Show all posts
Showing posts with label everybody. Show all posts

Wednesday, March 28, 2012

Update UpdatePanel using JavaScript

Hi Everybody,

i want to load dynamically content from some user controls (with forms,or some data-controls) using atlas. So i use an UpdatePanel for loadingthe user control into a placeholder.

Using buttons for loading new content works fine. But i still want touse a function which is callable per javascript. I think this way ismore flexable than using the Buttons, becaus every button needs it'sown Sub-Routine. But i want to have a function with an Parameter forloading the new content.

Has anybody a good idea how to realize this? Working with Update()-Function of UpdatePanel-Control doesn't logically work.

Here is some code:

At first my test-function

1 <WebMethod()> _
2Public Function Test(ByVal intIdAs String)As Boolean
3 Dim contentNameAs String = intId &".ascx"
4Dim contentControlAs Control = Page.LoadControl(contentName)
5
6 PlaceHolder.Controls.Add(contentControl)
7
8 UpdatePanel.Update()
9Return True
10 End Function

I called this per JS-Function ...

1function test(intId) {
2 PageMethods.Test(intId);
3}

... per onClick-Method of a Link

1<a href="#" onclick="test(1);">Test</a>
2
3 <atlas:UpdatePanel ID="UpdatePanel" runat="server">
4 <ContentTemplate>
5 <asp:PlaceHolder ID="PlaceHolder" runat="server">
6 </asp:PlaceHolder>
7 </ContentTemplate>
8 <Triggers>
9 <atlas:ControlEventTrigger ControlID="Button1" EventName="Click" />
10 <atlas:ControlEventTrigger ControlID="Button2" EventName="Click" />
11 </Triggers>
12 </atlas:UpdatePanel>

But it doesn't work. I have tried so much.

Is there a possibilty to get User Controls generated HTML Code?
Or has anybody an idea for realizing this with an other way?

Thanks for all hints.

Regards,

AndréHi Andre,

The main problem with what you are attempting to do is that you are attempting to make a modification to the page without actually performing a postback. Executing the web service method "Test" from Atlas using the PageMethod.Test statement will execute your web method, but doesn't actually perform a postback and therefore you can't modify your page. The web method can really only return data, not have ASP.NET re-render part of the page.

A simple, but maybe not the best way of accomplishing this, is to use a hidden text field and a button to provide postback data. You set the value of the hidden text box to the data needed to create the user control (i.e. intId) and then click the button programmatically (i.e. button1.click). Then you have a common routine on the server, like your web method "test", that alters the page as necessary based upon the postback information.

HTH
Hi,

thank you. But isn't there another method for loadig content dynamically per ATLAS?
Or is there a possibility to create a new event, bind the UpdatePanel-Trigger and raise it with JavaScript?

I believe there must be a cleaner method than using a hidden textfield and call a button's sub.
How do you this?

Best regards,

André
Hi,

I am relatively new to ASP.NET and Atlas but have a similar question. Is there any way to generate an Update event on the UpdatePanel using client side Javascript?

I have a situation where I need to have two separate web applications for security reasons, but I want both applications to use a common search page. I can create a link on the first page (parent) to open the search page as a popup window easily enough. What I want to do is return the found item id back to the parent window and trigger an asynchronous update when the popup window is closed.

If I use javascript only, I can have a function in the parent window called 'Update()' and use it to create the xmlhttprequest object etc. I would prefer to use an Atlas UpdatePanel in the parent window and trigger an update from the popup window using the onunload event. (Note: the popup window page is not in the same application as the UpdatePanel)

Is this possible? Is there a better way to achieve this?

Regards,
Trevor.
OK, so I think we agree that a web method isn't going to do the trick for you as the page needs to go through its lifecycle and process the new UserControl and render it into Html.

There is no magic bullet in Atlas to load content dynamically. An UpdatePanel requires a postback to do any updating. You can use a web method to return an Html string to you and then parse it and place it where you want in the DOM, but that really is a lot of work and doesn't require an UpdatePanel.

That being said I'll assume that we agree that a postback needs to occur in order to load your user control into the page.

I believe you need a generalized method of posting back data that is not really related to a server control. The question remains; how to get the data back to the server on which control to load? The data has to be part of the post data. I suggest using a hidden text box as the transport mechanism as it's easy to work with and is fairly light weight and then telling that UpdatePanel to update through the use of clicking a hidden button. To be honest, I've used this pattern on a multi-million dollar application and have good success with it. I'm not saying it's perfect and maybe I'll see a better pattern that Ishould'veused, but it provides the flexibilty that you and I require.

Happy Coding
"Is there any way to generate an Update event on the UpdatePanel using client side Javascript?"

You need to have whatever is defined as a trigger of the UpdatePanel or a server control contained within the UpdatePanel cause a postback.

Happy Coding
Thanks for explaining that. I wasn't aware of the PageMethods collection until just now.

Trevor.

BUMP!!!

That worked Marvellously :)

I used it with a calendar control. I wanted to have different controls in a date cause a postback. WELL as far as I know adding sever controls doesn't work because they don't cause post backs when added inside a Day Cell.

SO dropped some anchors in the day. Had the onclick of the anchor fill a hidden field and click a button outside the updatepanel. Which triggered it :)

Works great.

UpdateMode Conditional updates always

Hi everybody. Using MasterPage with ContentPaceholders that contains UserControls, UpdatePanels wich are all assigned an UpdateMode to conditional and some ModalPopUp extenders.

When any trigger is fired all the UpdatePanels are refreshed.

I'm I doing something wrong. Thanks in advance

I was wrong. It updates only with update method, but, always loads page and controls. Is it possible to avoid in a simple manner.

I was wrong. It updates only with update method, but, always loads page and controls.

Is it possible to avoid in a simple manner?


I also have the same problem...

any body have any idea to solve this problem???


Hey I got the solution for this problem !!!!

Set RenderMode Property of UpdatePanel to "Inline" for each UpdatePanel on page.

Also assign TargetPanelID for each UpdateProgress on page.

Cheers ,

Shekhar


Hello, this didn't help. Do I need to set "Conditional" update mode to the panels?Also, TargetControlID, not TargetPanelID I suppose, right?

updatepanel - Cannot unregister UpdatePanel

Hello everybody!

I have been trying to set programatically visible and unvisible of some Controls in my WebPage. On this Controls there are UpdatePanels.
On each control - one UpdatePanel.

I have a problem. If I try to change visible of UserControl, I get the error "Cannot unregister UpdatePanel ... since was not registered with the Script Manager". OK, I found the solution.
http://msmvps.com/blogs/luisabreu/archive/2006/11/16/adding-removing-updatepanels-dynamicaly-from-a-page.aspx
I have to set visible = true/false in "Page_PreInit" method, it works on single test site, but...

In my project I have a MasterPage, and in method Page_PreInit areference to my control is null, so I can't change visible, and masterpage has no PreInit method.

How to solve it ? Maybe you know some other solution to dynamic hide controls with updatePanel in it.

regards
bakuuu

Can you have the Controls in the UpdatePanel vs the UpdatePanel in the Controls? Seems like this design would work out better...

-Damien


I did it, but these controls are tabs. These tabs look like tabs I see, when I write this replay message (Reply: Compose, Options, Related, Preview). Just imagine, I want to hide some of these tabs.
In this moment I have one big UpdatePanel and all tabs inside. But, I don't like it. There is many controls in each tab (buttons, textBoxes ...) and it weight much. I want to divide these part of page.

bakuuu


Ahh, gotcha.

Well, you could just hide them client-side using the CSSdisplay:none; on the Tab's (not the panel, but the actual tab) outermost <SPAN>. Each tab has an ID assigned to it such as ...TABPANELNAME_tab. You need to just append the "_tab" to the end of the Tab Panel's ID. I have an article ontheming the tab which talks about the tab structure that may help.

-Damien

Monday, March 26, 2012

UpdatePanel (Triggers with controls of the Gridview)

English______________________________________________

hi Everybody...i have a control in my TemplateField (a collum of the gridview) with two controls (lnkDelete and lnkEdit), and it's in a UpdatePanel (ASP.NET AJAX). I wanna that when a user to click, on the edit controls...it'll do a postback... How do I configure mine UpdatePanel (Triggers)?

I'm Sorry, but my english isn't good...tanks you

Here are some sample codes to work asp:UpdatePanel with asp:GridView for your reference.
.ASPX:
<div>
<asp:UpdatePanel ID="UpdatePanelNestedGridView" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" CommandName="Delete"></asp:LinkButton>
<asp:LinkButton ID="lnkEdit" runat="server" Text="Edit" CommandName="Edit"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="userID" HeaderText="userID" InsertVisible="False" ReadOnly="True"/>
<asp:BoundField DataField="alias" HeaderText="alias" SortExpression="alias" />
<asp:BoundField DataField="pwd" HeaderText="pwd" SortExpression="pwd" />
<asp:BoundField DataField="hasForums" HeaderText="hasForums" SortExpression="hasForums" />
<asp:BoundField DataField="isAdmin" HeaderText="isAdmin" SortExpression="isAdmin" />
<asp:BoundField DataField="isDeleted" HeaderText="isDeleted" SortExpression="isDeleted" />
<asp:BoundField DataField="remark" HeaderText="remark" SortExpression="remark" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PerformancingConnectionString %>" SelectCommand="SELECT [userID], [alias], [pwd], [hasForums], [isAdmin], [isDeleted], [remark] FROM [Users]"></asp:SqlDataSource>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="RowCommand" />
</Triggers>
</asp:UpdatePanel>
</div>
Behind codes:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if(e.CommandName == "Delete")
{
//Delete a record here
}
else if(e.CommandName == "Edit")
{
//Edit current record here
}
}
Wish the above codes can give you some helps.

UpdatePanel + Dynamically UserControl

Hi everybody.

I have next problem, I have a menu with a couple of options, when youclick over any option the web load a usercontrol inside of aupdatepanel (i save the virtualpath of the control in a viewstate), oneof these controls has a uptatepanel with a gridview.

The option which load the usercontrol is Customers, when I click thefirst time over Customers, the usercontrol and the gridview work fine,but if i click one more time over this option the gridview doesn'twork, I press to sort one column, but the gridview isn't updated, it islike it was frozen.

Thanks, Pedro.

I have exactly the same problem.

I'm not sure, but I think that this issue is related to the fact that the second updatepanel it's n loot loaded at page init, so it's not going to work properly.

If anybody has found a solution to get updatepanels to work after loaded dynamically, please HEELP!!

Saturday, March 24, 2012

UpdatePanel and Gridview

English:

hi Everybody...i have a control in my TemplateField (a collum of the gridview) with two controls (lnkDelete and lnkEdit), and it's in a UpdatePanel (ASP.NET AJAX). I wanna that when a user to click, on the edit controls...it'll do a postback... How do I configure mine UpdatePanel (Triggers)?I'm Sorry, but my english isn't good...tanks you


Thanks everybody

Portuguese:

Olá, eu tenho um controle em uma templatefield (coluna de um gridview) com dois controles...(lnkDelete e lnkEdit), dentro de um UpdatePanel (ASP.Net AJAX). Eu quero que quando o usuario clique em no controle lnkEdit (de qualquer registro) a pagina fa?a um postback... (lembrando que o gridview está no updatepanel).

Obrigado

Put your code here so we can help you.

WS


Thanks

<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="lnkExcluir" runat="server" CausesValidation="False" CommandName="Delete" Text="Excluir" OnClientClick="return confirm('Deseja Realmente Excluir esta Noticia?');"></asp:LinkButton>
<asp:LinkButton ID="lnkEditar" runat="server" CausesValidation="False" CommandName="Editar" Text="Editar"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

After i'm programming on event RowCommand of the my GridView... (when i do my edition)... and i need a postback on linkbutton "lnkEdit"...

is it possible ??