Showing posts with label ideally. Show all posts
Showing posts with label ideally. 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">

Need an idea for clientside-loaded control container

I am working on an Expandable Row Extender that ideally youwould apply on a gridview (or any other databound control that renders a table)to give it an expandable row functionality. However, I want to do as much aspossible in client side (I've seen the approach of adding an item in thedataset, override onitembound to draw it accordingly and then rebind the datato the control to redraw it, and place it all in an update panel but I don'tlike this approach - obvious reasons). Nor do I like the idea of having every"details" row rendered and hidden.

I kind of like how this feels:http://www.codeproject.com/aspnet/MasterDetail.asp and I very much like how asimilar implementation on www.titlez.com.

That being said, I am trying to make the control as genericas possible (and as easy to use as possible), therefore I think the easiest foranybody to use for the details row would be a usercontrol (so that you can useyour own control, which eventually you might reuse as a webpart as well).

Here is where I need the idea: how to dynamically render thecontrol triggered from the client side (to render it in the expanded row).

The trivial solution would be to use an iframe and load aweb form that would load the control, but there is something that doesn't feelright about this approach.

Any ideas?

I think you can embed user controls to a GridView and implement a inline GridView similar to the demo in www.titlez.com.Besides,maybe a third party user control can be used in a GridView,specially about Chart/Graph controls.
Try to take a look at Ajax website - http://Ajax.asp.net.There are a lot of useful Ajax controltoolkit which can help you to implement it and get a nice web page.

Hi Jasson and thank you for your reply.

I know you can embed user controls in a gridview but what I am trying toachieve is a control that does as much as possible on client side (so when youwould expand a row I wouldn't want to hit the server to add a control in thegrid and rebind the grid, even if this would be in an updatepanel especially asyou might have some time-consuming info in the details row and if you wouldhave several open at the same time this architecture would severely affectperformance. Nor do I want to pre-render everything in one go and initiallyhide the rows for the same reason). Also I am not interested at this time aboutthe graphs and other nice things in those rows, I am just down to the very ideaof the extender control. I am well aware of the ajax controls toolkit and what I am doing isan extender using the same framework, actually extending the extenderbase inthe toolkit.

What I have done so far uses IFrames to render the details row and lets youdefine a usercontrol that will be rendered in the expanded row. It goes througha complicated process of autogenerating a form to host the control at runtime.I was looking for ideas of how to do this without IFrames, using somethingsimilar to an updatepanel that would be able to add the user control atruntime.

Hope this makes sense ..


If you would like to achieve a control as much as possible on the client side,javascript is the unique selection.Ajax control toolkit gives us a good direction to this,however,it can not implement what we need now.I believe it can be done in the near future.I agree with you that if we load too many user controls at runtime in the server side and embed them in a complicated control such as Grivew,DetailsView or FormView,it will affect the server performance. Do you mind MagicAjax which also provides a Ajax framework for us to do further development?MagicAjax is open source and we can extend it to meet our requrements.I don't know if you are inerested in it.

Try to take a look at this reading about MagicAjax for your reference -http://www.c-sharpcorner.com/UploadFile/mosessaur/magicajax02112006060506AM/magicajax.aspx?ArticleID=ddd4757e-7ab7-49da-a3f2-d88b340230c3

Wish this can give you some ideas.


Thanks for sharing the idea. I am afraid I am familiar with MagicAjax as well but I don't see it solving this particular issue. MagicAjax is actiong more like the UpdatePanel control in Ms. Ajax. That wouldn't work without rebinding the grid on the server which wouldn't be any faster. Further more, MagicAjax stores everything on the session so it might bring even more concerns.