Showing posts with label prevent. Show all posts
Showing posts with label prevent. Show all posts

Wednesday, March 28, 2012

Pre Fetching Data - InitialData Control?

Are there any features in ASP.NET AJAX for pre-fetching data? I'm thinking of a feature that would prevent the app from frequently pinging the web server for data (i.e. auto complete, cascading drop down).

From what I can tell, at one point there was an "InitialData" control that was aimed at sending a chunk of data down with the first request. It seems however that this control has been pulled from both Beta2 and the Futures. Does anyone know the status of this control?

Thanks!

Here is a solution for pre-fetching data for your reference.
????At any point in an Ajaxian application's lifetime, the user has the option to perform a number of activities. At the very least, there are always two things the user could do in the next moment: (a) close the application (by quitting the browser or closing the application window/tab); (b) nothing. And of course, there are usually a multitude of application-specific activities that can occur at any time.

Some of these user activities will trigger a remote scripting call to the server before returning for browser-side processing, and the delay will usually be noticeable. That's unfortunate for usability, because responses should ideally feel as if they are instantaneous. The computer not being able to freeze time, the response will never really be instantaneous. But from a usability perspective, it should ideally give that impression. To provide results at a pace that is below the level of human consciousness, a typical guideline is that the application should respond in under 10 milliseconds. That's a hard ask when a trip to the server is required. Especially in a global context, where a trip to the sever and back might cost a second or more due to network overheads.

The obvious motivation for instantaneous feedback is throughput: the user can achieve more because they're not waiting as long for results. Actually, that's not such a major issue: what's a few seconds when you're working on a document for half-an-hour?

Often, the biggest downside of latency is the distraction it causes. The user is focused on a task, and may well be in a state of "flow". A delay will cause a loss of concentration and, in addition to the time it takes to get back to this train of mind, there's also a risk that an idea might be lost forever.

Another problem is simply user frustration. Users generally like to feel in control of a system, so it's not ideal when the system causes delays, especially unpredictable delays.

A final issue with latency is its effect on responsivenes. When users are making decisions in real-time, they need real-time data. For an application such as financial trading, even a consistent 100-millisecond lead can make a big impact on overall performance.

Pre-fetching attempts to remove the delay altogether for certain user actions. It's usually infeasible to pre-fetch results for all actions, so the designer must be judicious in anticipating actions. We are especially interested in actions which are likely to be performed, so that the probability of no response is high. Furthermore, even unlikely actions may also be worth pre-fetching for, if they are critical to the application. Imagine an emergency response system, where the choices are "View your preferences", "Work on reports", and "Dispatch emergency units". The last of these might not occur very often, but which one would you like to be prefetched?

Another downside of pre-fetching is erratic behaviour. A good usability principle is consistent behaviour, but with Predictive Fetch, the user may be surpised that some commands respond instantaneously, while virtually identical commands take a long time. To make the waiting time more comfortable, consider showing a Progress Inidicator.
Advanced Networking Scenarios Not Available in the RTM Release
The following networking features of the CTP release willnot be available in the RTM release:
?The iframe executor. This feature provided support for cross-domain calls, and is not available in RTM release in part because of security concerns.
?The following infrequently used features:
oAssembly-based method calls.
oInitialData control.
oBatching of Web service calls.

Monday, March 26, 2012

prevent ajax functions used by Malicious users using HTTP POST

Hi Guys ,i have a problem in my site,i m having a class which is having ajax functions,problem is that Malicious users can access these ajax functions method using HTTP POST.so that he can do all the task using HTTP POST.

in config file i write following code.

<httpHandlers>

<addverb="POST,GET"path="ajax/*.ashx"type="Ajax.PageHandlerFactory,eAjax"/>

<addverb="POST,GET"path="ajaxpro/*.ashx"type="AjaxPro.AjaxHandlerFactory, AjaxPro"/>

</httpHandlers>

the malicious user use the functions using following Code.

Post

/ajax/al2006.ajaxFunctions,al2006.ashx?_deleteusers&_session=no.

so i want to prevent that problem.so pls give me any suitable solution of this.shall be thankful to all.

Thanks in Advance.

jkyadav

You can use the following line of Code in your Generic handler to check if the User is Authenticated:

if (HttpContext.Current.User.Identity.IsAuthenticated)
{
//Do what you need to do for authenticated users
}

prevent asp:ImageButton from refreshing image...

Is there a way (with the Dec release) to prevent the image in an image button from refreshing when posting back to the server in an UpdatePanel?

It would seem to defeat the purpose of Ajax to have this image refresh all the time during a post to the server...

Wade.

The idea would be to keep the image button outside the updatepanel so it is not refreshed when the page is posted back.

- Kashif


Actually the behavior is browser dependent. Internet Explorer seems to refresh images by trying to go to reload the image, while Mozilla seems to cache images completely locally and without that funky flash.

In IE if you replace content that contains images references (as UpdatePanel will do) all the images reload. Usually they will come from Cache so it's pretty fast, but there's still some amount of flash. If you use FireFox you don't get that flash. You can hook up Fiddler or other HTTP proxy to see this behavior.

Certainly makes for smoother operation of any sort of callback in FireFox.

+++ Rick --


The best method is to have a script manager control on the page with 'Enable Partial Rendering' set to 'True', and then only put the parts of your page that would be updated on a page refresh within the UpdatePanel controls.

So if you don't want the image to 'blink', it's best to leave it outside of that control.


This is a problem that is currently driving me nuts. I have a large UpdatePanel that has a tab control on it. The tabs are painted using image backgrounds defined in a stylesheet. In IE, using Nikhil's web dev tool, I can see that for every tab all the images are requested and the server responds with code 200. It's like IE's local cache is completely ignored. This is causing an ugly flicker and some repaint issues. I've tried the max-age cache control-cache extension but it doesn't seem to work. I found the best information athttp://aspnetresources.com/blog/cache_control_extensions.aspx.

Does anyboy have any ideas?

This bug is going to kill me too. all the images on the page even those are outside the updatepanel and wrote with <img> tag are flikering too.

Any solution to resolve this problem?


The image flicker has nothing to do with ATLAS - it's an IE bug - IE is refreshing the images when it shouldn't. You can fix that by changing your IE cache settings. I think it happens if you have your cache set to refresh on every page hit. IE apparently considers the partial XmlHttp postback as a page refresh and refreshes all content in the page. Put IE back to auto caching and the flickering should stop.

+++ Rick --


Dear Rick

Thanks For Comment

My IE Caching was set to Auto Already, and here still the killer bug.

Any other Idea?

H.B.F


Hello. This is a bug in IE when it's pulling in background images defined in CSS. As far as I am aware, the solution lies within IIS. Have a read of this: http://erik.eae.net/archives/2007/02/26/13.13.48/

cheers
Anthony

Prevent CHECKBOX in Update Panel

Hi there,i'm using CHECKBOX in Gridview Template Panel, and My Gridview is under UpdatePanel. The update panel will be refresh every 3 second using timer. how to prevent CHECKBOX from 'unchecking' when the user have already check the CHECKBOX ?Thanks.

Hi,

can you identify if it is due to slowly loading update panel or checkbox just loses its checked state on postback?

You can place just a button anywher eon the page (disable your timer before) and see if checkbox loses its checked value when you click this button.

-yuriy


The CHECKBOX just loses its checked state. I dont think palce a button anywhere is the solution for the application, since it'll have so much button. any ideas ?Thanks.

Hi,

an approach would be saving the checked boxes in an hidden field in the page. When a postback occurs, you parse the hidden field and extract the info about the checked boxes.

Since the GridView might be bound to different data each time, you have to associate an ID to each checkbox. The ID might be that of a database row, for example.

Then, when you're binding the GridView, you check whether the ID is in the list of checked boxes. If it is, you select the corresponding checkbox.

Sounds little complicated, but it should work.

Prevent child elements from firing parent element onclick event

This question does not appear to be directly related to the Ajax Client framework. However, I am asking it here because a) there is actually heavy use of Ajax in the real life issue, but it is not necessary to explain this to illustrate the problem and b) it is JavaScript related, and where better to find an answer to such a question than on this forum, with so many hardcore JavaScript experts visiting?

So, I hope you'll forgive the apparently off-topic nature of this post.

I have made the rows of a Gridview clickable. I have a hidden 'Select' button in each row, and in the code behind RowDataBound event I steal the JavaScript from this button and apply it as an 'onclick' attribute for the entire row.

In the resulting HTML, there is a TR element generated for each Gridview row. This TR element has the 'onclick' attribute, containing the necessary JavaScript to do a row 'Select' postback. If I now click anywhere in the TR element (i.e. anywhere in the Gridview row), the 'onclick' event is fired and a 'Select' postback occurs.

This is exactly what I want to happen, except for one instance. One of the Gridview row Cells (which corresponds to a TD element in the resulting markup) contains an <asp:HyperLink> control. When the user clicks on this HyperLink, a new window opens as it should. However, the 'onclick' event for the entire row also fires and the Gridview row ends up being selected.

As the <A HREF> element resulting from the HyperLink control is within the TR element which has the 'Select' onclick attribute, this onclick event is fired. I want to know how I can stop this.

To put it succinctly:
- I have a TR element with an 'onclick' attribute.
- I have an <A HREF> within the DOM hierarchy descending from the TR element.
- How can I stop the TR element 'onclick' attribute firing when I click on the <A HREF> link?

I've tried setting the 'onclick' event of the <A HREF> element to nothing, but it makes no difference.

A solution I have found is to replace the HyperLink control with a LinkButton control. I give the LinkButton an 'onclick' attribute which does a 'window.open' with the appropriate link. So the resulting behaviour is just like the HyperLink. But using a LinkButton involves a postback (albeit a dummy postback which does nothing at all other than reload the page), which wastes server resources and bandwidth. I could whack the LinkButton into an UpdatePanel to minimise this, but it still seems like overkill to me. And it would mean an UpdatePanel for each Gridview row, which is a lot of extra script for so simple a purpose.

So... any thoughts on this would be very much appreciated.

Thanks...

You should just be able to cancel the "bubble" event... seehttp://www.quirksmode.org/js/events_order.html

The code you want is in the section"Turning it off":

if (!e) var e = window.event;
e.cancelBubble = true;
if (e.stopPropagation) e.stopPropagation();

-Damien


Thank you very much. That is exactly the information I was looking for. I have to say, the more I find out about JavaScript the more impressed I am with it.

As well as solving the issue I had that is a very interesting read and I've bookmarked it for future reference.

Thanks again for your help, much obliged...

Prevent child control inside the updatepanel to refresh the updatepanel

let say i have 2 UpdatePanels UP1 and UP2. Up1 contains a dropdownlist with 3000 items. When selectedindex of the dropdownlist is changed, it fires a partial postback to refresh the controls inside the UP2 which uses trigger. but at the same time it also refreshes the UP1which i want to avoid. and i also need this dropdown list to be inside the Updatepanel because the selected index is changing during partial postback.

Currently what i have done is i took this dropdownList out of updatepanel and the UP2 gets refreshed using trigger of that dropdownlist, and when it is required to update the the dropdown list i 'm injecting the javascript code in partial postback to do this.

any better work around to achieve this.

Thanks in Advance

RG

Pushed...

Prevent Modal Popup from Moving on Async Postback?

I have a draggable a panel with a ModalPopupExtender with an UpdatePanel inside it. Whenever I have an asynchronous postback run, the popup "jumps" back to to the center of the screen. Ideally it would stay in whatever position it is currently in, as the jump is jarring to the user experience.

Anyone know a way to avoid this?

Thanks!

Hi MWB,

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Best regards,

Jonathan


Hi Jonathan -

Thanks very much for responding. I put together an extremely simple (and rather ugly, so forgive me) website project that reproduces the jumping modal popup behavior. Please let me know if you have any thoughts or questions. Since I can't directly upload the project files, the code is below.

Thanks again!

-Matthew

Default.aspx

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style>
*
{
font-family: Verdana, Helvetica, San-Serif;
}

.popupButton
{
font-weight: bold;
color: #C00;
}

.modalPopupBackground
{
background-color: #CCC;
filter: alpha(opacity=60);
opacity: 0.6;
}

.windowTitle
{
border: solid 2px #9CF;
background-color: #369;
color: #FFF;
font-size: 16px;
text-align: center;
padding: 10px 10px 10px 10px;
}

.window
{
width: 400px;
border: solid 2px #036;
background-color: #FFF;
padding: 5px 5px 5px 5px;
}

.windowContent
{
text-align: center;
margin: 10px 10px 10px 10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" /
<h1>Click this button</h1>
<asp:Button ID="Button_OpenPopup" runat="server" Text="Open Modal Popup" CssClass="popupButton" /
<div>
<h4>Junk text to allow dragging of Modal Popup</h4>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus vehicula nisi vitae elit. Vivamus metus diam, dignissim in, vehicula vitae, ultrices a, dui. Maecenas nec eros vel lacus gravida nonummy. Donec laoreet, metus vel interdum sodales, pede augue iaculis nunc, et venenatis sem mi sed elit. Donec arcu. Praesent nec magna. Nunc egestas lectus ac quam. Quisque in justo non tortor luctus faucibus. Fusce mattis dignissim diam. Phasellus gravida risus vel magna. Mauris commodo felis nec metus. Cras commodo euismod ante. Donec consectetuer nisl vitae nulla. Nam aliquet. Mauris semper velit id orci. Suspendisse elementum, pede et dictum molestie, mi ante pulvinar metus, ut varius massa dui et diam. Integer dictum fermentum ipsum. Nunc quis odio. Aenean vitae tellus.
</p>
<p>
In elit lectus, fermentum ac, fringilla accumsan, aliquam in, turpis. Praesent tempus sagittis augue. Aenean leo lectus, mattis ultricies, interdum sed, luctus ac, ligula. In hac habitasse platea dictumst. Vivamus placerat. Fusce turpis enim, tempor tempor, luctus at, bibendum id, sapien. Morbi feugiat ante eu eros. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin sed felis. Duis sit amet justo. Vivamus eu diam ac dui bibendum tempus. Vivamus quis neque sit amet felis rutrum tristique.
</p>
<p>
Pellentesque adipiscing accumsan est. Sed dignissim arcu nec orci. Sed euismod diam. Donec at tellus. Suspendisse mauris neque, pharetra et, pretium vitae, blandit ut, pede. Vestibulum aliquet, nisi eu varius congue, neque dolor ornare augue, ut iaculis lacus urna eget justo. Vivamus urna. Suspendisse ipsum diam, blandit sit amet, semper ut, cursus eu, leo. Cras pede lorem, rhoncus vitae, posuere ac, ultrices at, lacus. Cras in augue quis purus ultrices sollicitudin. Nam congue, magna id sodales suscipit, tortor tellus ullamcorper metus, blandit iaculis nunc eros id augue. Nam posuere erat quis est. Nunc porta leo et lorem. Nam cursus massa et arcu. Proin augue diam, blandit ut, imperdiet a, elementum nec, purus. Pellentesque metus mauris, dignissim ac, dignissim et, venenatis in, massa. Curabitur eget dui sit amet erat tincidunt volutpat. Fusce vel nibh quis erat blandit posuere. Mauris porta, erat sit amet tincidunt commodo, augue lectus porttitor nulla, nec lobortis lacus elit ut elit. Cras feugiat posuere justo.
</p>
<p>
Cras a velit id massa ornare commodo. Donec egestas. Vestibulum sed felis. Etiam aliquam, tellus sit amet consectetuer bibendum, dui ante volutpat ligula, at semper lacus tellus a lorem. Sed et elit. Integer nisi purus, suscipit ac, nonummy nec, placerat eget, diam. Nullam sodales. Quisque erat pede, ultrices non, cursus ut, euismod vel, sem. In hac habitasse platea dictumst. Ut sit amet est. Nulla pellentesque. Quisque non dolor. Vestibulum mi arcu, accumsan ac, ullamcorper mollis, dignissim eu, urna. Vestibulum metus quam, congue eget, tempus quis, pellentesque ac, eros. Suspendisse risus lectus, interdum nec, tristique ut, auctor eu, urna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Etiam ac mi. Sed eget arcu. Curabitur eu libero sit amet odio fringilla pharetra. Aenean arcu.
</p>
<p>
Donec malesuada. Phasellus sapien risus, tristique sit amet, varius id, iaculis sit amet, purus. Morbi egestas risus et turpis. Curabitur quis quam. Vestibulum tortor sem, feugiat id, laoreet et, egestas at, metus. Aenean pellentesque tellus sed metus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus lacinia tempor erat. Vestibulum pharetra, sem vel porttitor lobortis, libero erat ultricies nulla, sed suscipit justo lorem vel nisi. Sed at sapien. Maecenas vestibulum elementum odio. Duis sagittis, diam vel posuere egestas, sapien lorem vulputate metus, faucibus rhoncus diam nulla sed est. Mauris imperdiet. Nulla sagittis. Aliquam velit arcu, facilisis in, tempus vel, hendrerit in, dolor. Ut lacinia est non neque nonummy ullamcorper.
</p>
<p>
*** sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet orci eu neque imperdiet imperdiet. Phasellus blandit mauris nonummy urna. Phasellus lacinia vestibulum felis. Fusce ullamcorper egestas sem. Donec auctor, lacus nec vulputate convallis, nunc purus vehicula erat, vitae blandit purus mi at lectus. Suspendisse tincidunt. Donec id justo. Sed eros augue, lobortis non, rhoncus quis, fermentum porta, risus. Pellentesque egestas condimentum quam. Nullam neque. Vivamus convallis tellus ut mauris. Phasellus luctus dapibus nibh. Phasellus pulvinar massa non nisi. Aenean malesuada euismod lacus. *** sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce vitae tortor non diam pellentesque consectetuer. Curabitur tincidunt nunc sit amet turpis.
</p>
<p>
Donec est turpis, mattis in, scelerisque non, aliquet elementum, libero. Quisque mauris erat, rhoncus sit amet, tristique vitae, condimentum in, nunc. Vivamus quam nisl, tincidunt vel, consequat eu, sodales id, mauris. Nam eu eros id massa cursus pellentesque. Etiam quis metus in mi fringilla lacinia. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse ac nisi. In hac habitasse platea dictumst. In hac habitasse platea dictumst. Sed sodales porttitor dolor. Vestibulum risus. Mauris augue augue, ultricies vitae, adipiscing in, elementum sit amet, nunc.
</p>
<p>
Pellentesque pulvinar dignissim quam. Donec sed justo et elit semper interdum. Duis nec leo ac urna pellentesque eleifend. Morbi consectetuer purus ut felis. Nulla euismod fermentum enim. Ut aliquet tellus at justo. Sed purus. Phasellus porttitor commodo ligula. Phasellus sem. Donec non orci. Donec in nibh in lorem lacinia sagittis. Aenean vestibulum dictum sem. Sed ligula. Maecenas pharetra laoreet velit. Nam vitae mauris nec tellus cursus tincidunt. Curabitur malesuada massa feugiat nisl. Maecenas dapibus aliquam diam. Pellentesque ac dolor. Proin sagittis ultricies dui.
</p>
<p>
Ut vel orci sagittis odio tempor porta. Cras vitae nunc. In sollicitudin pharetra sapien. Donec imperdiet. Aenean egestas dui a mi. Cras mauris velit, tincidunt sed, tempor et, sollicitudin et, arcu. Quisque turpis lorem, hendrerit quis, blandit quis, convallis eget, pede. Etiam lacus lectus, molestie vitae, egestas pellentesque, dapibus sit amet, est. Suspendisse nibh dolor, bibendum a, sollicitudin sollicitudin, pulvinar sed, magna. Proin in nunc. Praesent blandit tempus magna. Aliquam erat volutpat. Morbi mattis. Nunc pretium laoreet ante. Integer eros nisi, luctus sed, commodo quis, tincidunt quis, ipsum. Morbi magna dolor, tempor id, sagittis faucibus, adipiscing at, dui. Sed ornare, orci non lobortis viverra, nibh enim auctor lorem, at bibendum lacus massa et eros. Phasellus luctus. Suspendisse volutpat nunc eget augue.
</p>
<p>
Curabitur vulputate. Donec nunc lorem, porta accumsan, pretium nec, scelerisque aliquet, ligula. Aenean eleifend aliquam lorem. Quisque facilisis. Nullam porta. Vivamus congue dapibus libero. Vestibulum placerat bibendum enim. Sed diam eros, lobortis vel, varius a, pretium et, nibh. Nulla nisi dui, malesuada eu, lobortis tincidunt, mattis nec, leo. Proin massa mauris, interdum et, elementum vitae, ornare ut, lorem. Fusce erat massa, dignissim sed, viverra sit amet, euismod in, magna. Donec consectetuer porta odio.
</p>
</div
<asp:Panel ID="Panel_PopupWindow" runat="server" CssClass="window">
<asp:Panel ID="Panel_Panel_PopupWindowTitle" runat="server" CssClass="windowTitle">
<p><strong>Drag Me</strong></p>
<asp:Button ID="Button_ClosePopup" runat="server" Text="Close Modal Popup" />
</asp:Panel
<asp:Panel ID="Panel_PopupWindowContent" runat="server" CssClass="windowContent">
<asp:UpdatePanel ID="UpdatePanel_PopupWindowContent" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="True">
<ContentTemplate>
<div style="text-align: left;">
<p>How to reproduce the jumping Modal Popup issue:</p>
<ol>
<li>
Drag the popup using the blue box that says "Drag Me" above
so that the popup is no longer in the default centered location
</li>
<li>Click "Generate Asynchronous Postback"</li>
<li>
Note how the popup "jumps" back to the default
center location. This is the behavior I wish to avoid.
</li>
</ol>
</div>
<p><strong>Any ideas? Thanks!</strong></p>
<p><asp:Literal ID="Literal_Test" runat="server" /></p>
<asp:Button runat="server" Text="Generate Asynchronous Postback" OnClick="ShowDate" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" EnableViewState="true" TargetControlID="Button_OpenPopup" PopupControlID="Panel_PopupWindow"
CancelControlID="Button_ClosePopup" PopupDragHandleControlID="Panel_Panel_PopupWindowTitle" BackgroundCssClass="modalPopupBackground" />
</form>
</body>
</html>

Default.aspx.cs

using System;
using System.Web.UI.WebControls;
public partialclass _Default : System.Web.UI.Page
{
protected void ShowDate(object sender, EventArgs e)
{
Literal_Test.Text = System.DateTime.Now.ToString();
}
}

Web.Config

<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
</controls>
</pages>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
</webServices>
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
</configuration>

Hi MWB,

Thanks for your sample.I have reproduced your problem with your sample.

Based on my research and testing, I'm afraid that what your want is not achievable in your case.It will automaticlly reset to orignal position when a post occured.Thanks.

Best regards,

Jonathan

Prevent popupcontrolextender from full postback.

I follow the sample popupcontrol from the samplewebsite package. I spent couple hours trying to figure out where I'm doing wrong: the asp:control, the popupcontrolextender, or the updatepanel. Everytime I click submit in the popup box it does a full postback. The popupcontrolextender's popupcontrolid is using asp:panel. I know the updatepanel inside the asp:panel is working, because I pulled it out from the popupcontrolextender and the asp:panel.

Maybe it is the asp:control I'm using, the asp:hyperlink to execute the popupcontrolextender. But, I need to use something similar to asp:hyperlink.

Here is my markup code:

1<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" CodeBehind="TestAjaxControlToolkit.aspx.vb" Inherits="AjaxSandbox.TestAjaxControlToolkit" %>
2<%@dotnet.itags.org. register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" >
5<head runat="server">
6<title>Ajax Control Toolkit</title>
7</head>
8<body>
9<form id="form1" runat="server">
10<asp:scriptmanager id="ScriptManager1" runat="server" />
11<%=DateTime.Now.ToString %>
12<br />
13If the date and time above change, means the whole page postback.
14<hr />
15<h3>PopupControl</h3>
16<asp:label id="lblFirstName" runat="server" text="First Name:" /> <asp:textbox id="txtFirstName" runat="server" /> <asp:hyperlink id="hypFirstNameNote" navigateurl="#" runat="server">[Note]</asp:hyperlink>
17<cc1:popupcontrolextender id="pceFirstName" runat="server" targetcontrolid="hypFirstNameNote" popupcontrolid="pnlNotePopup" position="bottom" />
18<br />
19<br />
20<asp:label id="lblLastName" runat="server" text="Last Name:" /> <asp:textbox id="txtLastName" runat="server" /> <asp:hyperlink id="hypLastNameNote" navigateurl="#" runat="server">[Note]</asp:hyperlink>
21<cc1:popupcontrolextender id="pceLastName" runat="server" targetcontrolid="hypLastNameNote" popupcontrolid="pnlNotePopup" position="bottom" />
22<br />
23<div style="visibility:hidden;position:absolute;">
24<asp:panel id="pnlNotePopup" runat="server">
25<div style="width:320px;padding:0.2em 0.2em;border:1px outset gray;background:white;">
26<asp:updatepanel id="upNotePopup" runat="server">
27<contenttemplate>
28<asp:textbox id="txtNote" runat="server" rows="6" width="98%" textmode="MultiLine" />
29<asp:button id="btnNoteSubmit" runat="server" text="Submit" onclick="btnNoteSubmit_Click" />
30<asp:hiddenfield id="hidNote" runat="server" />
31</contenttemplate>
32</asp:updatepanel>
33</div>
34</asp:panel>
35</div>
36<br />
37<asp:updatepanel id="upOutputSubmit" runat="server">
38<contenttemplate>
39<asp:button id="btnOutputSubmit" runat="server" text="Submit" onclick="btnOutputSubmit_Click" />
40<br />
41<asp:label id="lblOutput" runat="server" />
42</contenttemplate>
43</asp:updatepanel>
44<h3>DropDown</h3>
45</form>
46</body>
47</html>

Here is my vb.net code:

1Public PartialClass TestAjaxControlToolkit
2Inherits System.Web.UI.Page
34Protected Sub btnNoteSubmit_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)
5 hidNote.Value &= HttpUtility.HtmlEncode(DateTime.Now.ToLongTimeString &": " & txtNote.Text &"<br />")
6 txtNote.Text =String.Empty
7End Sub
89 Protected Sub btnOutputSubmit_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)
10 lblOutput.Text ="<br /><strong>Output General:</strong><br />" & txtFirstName.Text &" " & txtLastName.Text &"<br />" &"<strong>Output Note:</strong><br />" & HttpUtility.HtmlDecode(hidNote.Value)
11End Sub
1213End Class

*Bump*

Anybody?


*Bump*

Anybody home?


The sample seems to work fine for me with the 61106 Toolkit release and ASP.NET AJAX Beta 2. Try that configuration, please.

prevent refresh between screens

Hi,

I want to prevent refresh between screens.I have menu in the top of screen and when I pass between screens I want that this menu be static and don't refresh.

How can I do it?

Hi Rayak,

If you want the menu on the top to don't refresh when you are opening another webpage it isn't possible. Openening a new page can't stop your menu from flickering. If you want to stop it from refresing when events happen on your page you can use an updatepanel. Put you menu in the updatepanel and asign trigger (controls) to the updatepanel. Hope this helps!

Regards,


I use Master Page .All menu is in Master Page.If I put updatepanel in Master Page ,it doesn't work.

Hi RayaK,

When you are using masterpages and you put your menu in the masterpage this will make it available to al the content pages that deriv e from that master page, but al the content pages are still different aspx pages. When you make a request to defaultB.aspx when you are at defaultA.aspx you are requesting a total new page which means that the menu will be rendered again but on another page (flickering). UpdatePanels are used when you want to update parts of a webpage. You stay at the same webpage but you need to update a part of a webpage. Hope this helps.

Regards,


Hi,

Ok,I understand.Maybe do you know another method how to do it?


Hi RayaK,

No i don't know a solution for this. i think that for now it isn't possbile so your menu will be flickering when you go to another page. SorryWink. Good luck with Ajax development

Regards,


Dennis van de Laar:

Hi RayaK,

No i don't know a solution for this. i think that for now it isn't possbile so your menu will be flickering when you go to another page. SorryWink. Good luck with Ajax development

Regards,

If you have a master page you can use that in the default.aspx. In the default page you can set an update panel arround the content zone with update method set to conditional and having the menu as a trigger. Now, inside the update panel all you need is a dynamic web user control loader that loads a control based on the user menu selection.

I'm pretty sure this architecture works, although I never tested it.

Also, note that approaching the problem in this way is not much different than loading the whole page again. When u wrap all this information in an update panel everything will travel back and forward on the wire...
Using custom AJAX callbacks is much more efficient.


HI DBA,

I disagree with you. The way you describe your solution isn't working. Some very simple test can made. I created 1 masterpage with an scriptmanager and an UpdatePanel. In the updatepanel is a contentplaceholder. I have 2 buttons on the masterpage. One is navigating to Page1 and one is navigating to Page2. Then i created 2 contentpage based on the masterpage. I put on both pages a label in the contentplaceholder which will be set with the name of the page. When i click on the buttons on the masterpage it will build the webpage from scratch, because its a new page.

One thing is true. when i also put a button in the contentplaceholder which will set the label.Text from NAME OF THE PAGE to the CURRENT DATE. This will be done by partial rendering. This is correct because you stay on the same page and you are in the updatepanel which is deployed on the masterpage

MasterPage:

<%

@.MasterLanguage="C#"AutoEventWireup="true"CodeFile="UpdatePanelMasterPage.master.cs"Inherits="Masterpage_UpdatePanelMasterPage" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Page1"/><asp:ButtonID="Button2"runat="server"OnClick="Button2_Click"Text="Page2"/><div><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:contentplaceholderid="ContentPlaceHolder1"runat="server"></asp:contentplaceholder></ContentTemplate></asp:UpdatePanel></div></form>

</

body>

</

html>

ContentPage1:

<%

@.PageLanguage="C#"MasterPageFile="~/Masterpage/UpdatePanelMasterPage.master"AutoEventWireup="true"CodeFile="UpdatePanelMaster.aspx.cs"Inherits="UpdatePanelMaster"Title="Untitled Page" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:Buttonid="Button1"runat="server"OnClick="Button1_Click"Text="Button"/><br/><asp:Labelid="Label1"runat="server"Text="Label"></asp:Label>

</

asp:Content>

Code behind:

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclassUpdatePanelMaster : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

this.Label1.Text ="Page1";

}

protectedvoid Button1_Click(object sender,EventArgs e)

{

this.Label1.Text =DateTime.Now.ToString();

}

}

ContentPage2:

<%

@.PageLanguage="C#"MasterPageFile="~/Masterpage/UpdatePanelMasterPage.master"AutoEventWireup="true"CodeFile="UpdatePanelMaster2.aspx.cs"Inherits="UpdatePanelMaster2"Title="Untitled Page" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:Labelid="Label1"runat="server"Text="Label"></asp:Label>

</

asp:Content>

Code behind:

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclassUpdatePanelMaster2 : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

this.Label1.Text ="Page2";

}

}

Regards,


Dennis van de Laar:

HI DBA,

I disagree with you. The way you describe your solution isn't working. Some very simple test can made. I created 1 masterpage with an scriptmanager and an UpdatePanel. In the updatepanel is a contentplaceholder. I have 2 buttons on the masterpage. One is navigating to Page1 and one is navigating to Page2. Then i created 2 contentpage based on the masterpage. I put on both pages a label in the contentplaceholder which will be set with the name of the page. When i click on the buttons on the masterpage it will build the webpage from scratch, because its a new page.

One thing is true. when i also put a button in the contentplaceholder which will set the label.Text from NAME OF THE PAGE to the CURRENT DATE. This will be done by partial rendering. This is correct because you stay on the same page and you are in the updatepanel which is deployed on the masterpage

HelloDennis van de Laar,

That wasn't at all what I suggested:

I suggested you to try the following structure:

[MasterPage]
<asp:ScriptManagerID="ScriptManager"runat="server" />
<asp:contentplaceholderid="cphMainContent"runat="server">
</asp:contentplaceholder>

[Default.aspx]

<%@.PageLanguage="C#"MasterPageFile="~/MasterPages/Default.master"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="MasterPages_Default"Title="The dynamic saga" %>

<asp:ContentID="MainContent"ContentPlaceHolderID="cphMainContent"Runat="Server">
<asp:Buttonrunat="server"ID="btnLoadPage1" text="Load page 1"OnClick="btnLoadPage1_Click" />
<asp:UpdatePanelID="UpdPnlMainContent"runat="server">
<Triggers>
<!-- Insert Menu trigger here -->
</Triggers>
<ContentTemplate>
<asp:PlaceHolderrunat="server"ID="phMainContent" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content
[Default.aspx.cs]
protected void btnLoadPage1_Click(object sender, EventArgs e)
{
Control ctrlDynamicPage = LoadControl("~/WebUserControls/Page1.acx");
phMainContent.Controls.Add(ctrlDynamicPage);
}

Again, I haven't tested this code but this was what I had in mind. In order to add more pages you just need to create them in web user controls and then make sure you have a DB or something with the virtual path the loader needs to fetch.

Best regards,
DBA


Hi DBA,

I see what you suggest. I don't know if this is the solution for Rayak. The solution you suggest stays on the same page and reloads it with usercontrols. This can be a solution. if its possible to create a trigger from a control of the masterpage.

Regards,


Dennis van de Laar:

Hi DBA,

I see what you suggest. I don't know if this is the solution for Rayak. The solution you suggest stays on the same page and reloads it with usercontrols. This can be a solution. if its possible to create a trigger from a control of the masterpage.

Regards,

You don't have to do that. You just need to have something like this in your web user control:

<asp:Button runat="server" ID="btnMyAction" OnClick="DoSomething" /><asp:UpdatePanel UpdateMode="Conditional"><Triggers><asp:AsyncPostBackTrigger ControlId="btnMyAction" EventName="Click" /></Triggers><ContentTemplate><asp:Label runat="server" ID="lblTest" Text="not updated" /></ContentTemplate></asp:UpdatePanel>
In the code behind of the web user control:
protected void DoSomething(object sender, EventArgs e){ lblTest.Text ="updated by ajax callback";}
With this you are encapsulating the update panels, which again is not the optimal solution if you are considering resources. But, the bottom line is that it should work and solve the presented problem.
Best regards.


If RayaK just wants to prevent the static content flickering when navigating between screens:

- if your content is really "static" (the position, height etc. are the same for each page) you won't get flicker on firefox (not 100%, sometimes even firefox flickers)

- ie6 and (saddly) ie7 usually will flicker, but you can eliminate this flicker with the following in the codebehind (put it in the oninit or onload). (Firefox simply ignores this.)

HtmlMeta meta = new HtmlMeta( );
meta.Attributes.Add( "http-equiv", "Page-Enter" );
meta.Attributes.Add( "content", "progid:DXImageTransform.Microsoft.Fade(duration=0)" );
this.Header.Controls.AddAt( 0, meta );

This trick and forms are well "documented" all over the web.

prevent repeat animation (animationextender)

Hey guys. I have a textbox which will expand when I click it. However, once expanded it's still obviously active and it will replay the animation when I click it again. How can I make the textbox expand (like the example below) when clicked, but then disable further animations of it? I obviously cant disable the textbox. I was thinking a conditionanimation would work but Im not that great with javascript.
<ajaxToolkit:AnimationExtender id="Ani" runat="server" TargetControlID="TextBox1"> <Animations> <OnClick> <Resize width="400px" duration="0.3" fps="10" /> </OnClick> </Animations></ajaxToolkit:AnimationExtender><asp:TextBox ID="TextBox1" Width="200px" TextMode="MultiLine" Rows="6" runat="server" />
Thanks /J

Hi,

Yeah , a conditional animation would be the way to go about this .

Try this Mark-Up ..

<

scriptlanguage="javascript">var expandCount = 1;var expandMaxCount = 1;

function ShouldIExpand()

{

var shouldExpand =false;

if ( expandCount <= expandMaxCount )

shouldExpand =

true;

expandCount++;

return shouldExpand ;

}

</script>

<OnClick>

<ConditionConditionScript="ShouldIExpand()">

<Resize width="400px" duration="0.3" fps="10" /></Condition> </OnClick>

Hope this helps.

If it resolves the issue , please mark my reply as the answer


exactly what i had in mind, it works! ThanksYes

preventing the tab index change if certain conditions exist

Hello,

I have a form with a tab panel control

Tab container name (client id) : Tabs

I would like to know how to set and prevent the tab from moving from index 0 if the request.querystring("pid") is empty or null.

Here is my current javascript:

<scripttype="text/javascript">function PanelClick(sender, e) {

var mpid = gup('pid');

if (mpid=="") {

SetActiveTab("Tabs",0);

}

}

function ActiveTabChanged(sender, e) {var mpid = gup('pid');

if (mpid=="") {

alert("Please choose a page or create a new page first");

returnfalse;

}

}

function SetActiveTab(tabControl, tabNumber)

{

var ctrl = $find(tabControl);

ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);

}

function gup( name ){name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS ="[\\?&]"+name+"=([^&#]*)";

var regex =new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results ==null )return"";

else

return results[1];}

</script>

I guess all I need is the javascript reference to the active tab...

can anyone help me with this?

Ok, through a little more research, I found out how to navigate or prevent navigation of the tabs control via javascript:

Here's the code

<scripttype="text/javascript">

/

function ActiveTabChanged(sender, e) {

var mpid = gup('pid'); // get the querystring in the url by calling the gup function below... good little snippet for querystrings in javascript.

var activeTab = $get("Tabs"); // gets the element by the id of "Tabs" and defines the control variable activeTab.

activeTab.value = sender.get_activeTabIndex(); // gets the active tab index of the control.

if (mpid=="" && activeTab.value!=0) { // if the conditions aren't right then don't allow the user to navigate to any other tab.

alert("Please choose a page or create a new page first"); // alert the user.

SetActiveTab("Tabs",0); // sets the active tabreturnfalse; // doesn't allow the process to go to another tab.

}

}

function SetActiveTab(tabControl, tabNumber)

{

var ctrl = $find(tabControl);

ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);

}

function gup( name ){name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS ="[\\?&]"+name+"=([^&#]*)";

var regex =new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results ==null )return"";

else

return results[1];}

</script>

I hope that the scripts above can help someone else.