Partial Posts in asp.net - asp.net

I am working on asp.net. and i want to implement partial posts in my application. my situation is like that
i dont want to url changed in address bar and even page should not refreshed at all.
for that i used script manager and update panel but still page refreshes and url also changes.
so any one have idea about it what to do?
Thank you

If you are using Update panel and still your page is getting post back in that case check that EnablePartialRendering should be true. If this is not the case then check your configuration and all the handlers as registered properly for AJAX.
I will suggest you to use jQuery instead of update panel for partial page post back. Do a google and you will find lot of example on this.
Check this ASP.NET postback with jQuery?

Related

SilverStripe Ajax and Page Controllers

I have a very short question regarding Silverstripe. I have not found a solution anyway on the internet or here. I currently have a form on SS4 that when submit it will run an AJax request and render new content (page). The problem I have is that the content does not display and it seems to be related to the fact that the content that is rendered in is managed by a different Page controller. So it could not find the content when rendering through Ajax from another page. How would I resolve this without refreshing the page ?
Thanks in advance !
you would submit to the same page, which has a function to generate/return the new page. note that when submitting via ajax you need to include the FormAction button in the submitted fields.

Asp.net output cache substitution with postback in user control

We have a site where all pages are output cached, i.e. the caching is on aspx-level with VaryByParam="*". Now there is a requirement to make a gallup control, i.e. a small "How is this site working for you?" and then when the user clicks an answer the results are shown.
The gallup is implemented as a usercontrol that is added to the master page so gallups can be added to any page to which a gallup is created in the cms. The problem is that output cache naturally caches all clicks so when user no 2 votes he sees the results that where calculated after the first vote on that alternative.
Now I'm trying to use cache substition. I added an asp:Substition tag where the user control used to be, load the control dynamically and render it (using this approach http://coderwall.com/p/4ajzqq). The problem is that the postbacks that voting triggers is never fired. Apparently the method that the substition control executes is loaded outside the page life cycle or too late.
Any ideas?
Regards,
Mathias
I solved this by skipping the substitution control and just used the user control as normal, so the gallup/question view was output cached. Then in the click handler for the answer alternatives I added
Response.Cache.SetNoServerCaching();
which exempted the results view from output cache and hence it was updated as it should.
It is also possible to use Response.Cache.SetNoServerCaching() in Global.asax, using VaryByCustom. It merely requires sensing in Global.asax whether the page is a post-back or not. Here is a code example.

Getting Lightbox to Appear over Referring Page

I am working in ASP.NET (framework 2.0) with Master Pages.
I have a page that requires registration and then the user gets kicked back to the referring page.
I need to figure out how to provide a success lightbox that appears over the referring page, not the registration page (the event is fired on form submit).
I have the inline stuff in the master page and the scripts and everything fires just fine but the form is refreshed with the new (referring) page and the DIV gets hidden again.
Is sessions the only way to go here? Is there a way of having one lightbox appearing from the master page regardless of what the sub-pages are doing?
Thanks.
There should be a successful registration event. Can you emit some javascript in that scenario that would cause a redirection to the referring page. You could pass a parameter which would indicate that a light box should show up. I don't think you can redirect directly from successful registration because I am guessing that some cookie would need to be set- which the framework should handle. I might be off, but that is where I would start. I would try and avoid Session if possible.

Running code/script as a result of a form submission in ASP.NET

An outside vendor did some html work for us, and I'm filling in the actual functionality. I have an issue that I need help with.
He created a simple html page that is opened as a modal pop-up. It contains a form with a few input fields and a submit button. On submitting, an email should be sent using info from the input fields.
I turned his simple html page into a simple aspx page, added runat=server to the form, and added the c# code inside script tags to create and send the email.
It technically works but has a big issue. After the information is submitted and the email is sent, the page (which is supposed to just be a modal pop-up type thing) gets reloaded, but it is now no longer a pop-up. It's reloaded as a standalone page.
So I'm trying to find out if there is a way to get the form to just execute those few lines of c# code on submission without reloading the form. I'm somewhat aware of cgi scripts, but from what I've read, that can be buggy with IIS and all. Plus I'd like to think I could get these few lines of code to run without creating a separate executable.
Any help is greatly appreciated.
If you don't want the page to reload after submission, you will need to use AJAX. that is alot more complicated. you would still need the submit.aspx, you cannot send email with javascript.
Code a redirect after the form submission, so instead of getting the same form back in the main document/page, you could get something like a blank page saying "Thanks for your submission!" or something of that nature.
Might be more simple to redirect the user to a result page using Respone.Redirect that displays some sort of "Your email has been sent" message, or even just redirect back to the base page.

javascript conflicts UpdatePanel

I'm using a ReportViewer control which often runs into problems with the javascript associated with UpdatePanels in ASP.NET. I've created a second page which is very simple, no Update Panels. What's the best way to link the two pages? An iframe sounds bad. However, having to run a report, then be returned a link to the results also sounds bad. Sending the user to the simple display won't work in this case. Any suggestions, am I seeing things wrong here?
What I would do is rewrite the page that uses an update panel such that it uses straight javascript web method calls. This would remove the need for the reportviewer control to be on a seperate page because you would no longer need an update panel.

Resources