Showing posts with label Ajax. Show all posts
Showing posts with label Ajax. Show all posts

May 18, 2010

7:23 PM - , No comments

'Sys' is undefined

Some time you meet the error 'Sys' is undefined when you try to load your page. It occurs when you declare something like: Sys.Application.add_load(PageLoad); but your page does not recognize what Sys is.

Oke, try this:
1/ Register script (place in the top of .aspx file):
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>


2/ Place this snip code inside your <form> tag:

<div> <asp:toolkitscriptmanager id="ToolkitScriptManager1" runat="server">
</asp:toolkitscriptmanager></div>

Mar 25, 2010

4:20 AM - No comments

Popup doesn't fire in the second.

- Show up a popup window on the first time, every thing seems OK.
- Close this popup and then open it gain, the popup doesn't load the latest data.
- Event if you try to debug, the process doesn't go to PageLoad().
- What's up ?

Cheat:
Place this snip code in Popup PageLoad:

Response.Cache.SetCacheability(HttpCacheability.No Cache);
Response.Cache.SetExpires(DateTime.Now-new TimeSpan(1,0,0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(fa lse);

Feb 7, 2010

11:45 PM - ,, 1 comment

Disable CallOut Validator

AjaxToolkit ValidatorCalloutExtender control provides you a new (of course, a nice) way to display your validate message. Although still have some inconveniences but it's worth to try :))

One of inconveniences is when you disable your target validator control by JavaScript (4 example, call ValidatorEnable(targetValidateControl, false)) the callout validator popup still shows every time you focus to the control.

Here's the solution to fix this issuer :

1.Set CSS class for ValidatorCalloutExtender:

HTML Code:

<style id = "style1" type="text/css">
.CustomValidator
{
position: relative;
margin-left: -80px;
margin-top: 8px;
display: inherit;
}
</style>
<ajax:ValidatorCalloutExtender ID="ProductIncrementVE" runat="server"
TargetControlID="ProductIncrementValidator"
HighlightCssClass="validator"
WarningIconImageUrl="~/img/blank.gif"
CssClass="CustomValidator">


</ajax:ValidatorCalloutExtender>

2 . Use JavaScript to alter this CSS class when needed. Set display = none:

Mã:

function alterDisplay(type) {
var styleSheet, cssRule;
if (document.styleSheets) {
styleSheet = document.styleSheets[index1];
if (styleSheet) {
if (styleSheet.cssRules)
cssRule = styleSheet.cssRules[index2]; // Firefox
else if (styleSheet.rules)
cssRule = styleSheet.rules[index2]; // IE
if (cssRule) {
cssRule.style.display = type;
}
}
}
}

Note: the index1 and index2 may be difference from pages, it's up to your declaration. You can use IE debugger to find our the correctly index.
Hope they fix this problem in next release.