Friday, December 5, 2008

AJAX Exceptions


Sys.WebForms.pageRequestManager TimeoutException : the server request timed out
Solve this error by setting the executionTimeout inside ScriptManager


Sys.WebForms.PageRequestManagerParserErrorException: The message received from the
server could not be parsed. Common causes for this error are when the response is
modified by calls to Response.Write(), response filters, HttpModules, or server
trace is enabled.

"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the
server could not be parsed. Common causes for this error are when the response is
modified by calls to Response.Write(), response filters, HttpModules, or server
trace is enabled.".

Solution http://siderite.blogspot.com/


Sys.WebForms.PageRequestManagerParserErrorException:
The message received from the server could not be parsed.
Common causes for the error are when the response
is modified by calls to Response.Write(), response, filters,
HttpModules, or server trace is enabled.
Details: Error parsing near '/div> | '.













Asynchronous (independent) postbacks through the "life cycle" is the same as the
regular pages. The differences occur at the time of rendering. With AJAX,
rendering happens in the partial rendering occurred in the course is in the
UpdatePanel. Render the process of using the "special form" that is only understood
by the JavaScript on the client.

When there are interfensi of the data that is sent to the client
(in the form of a special format that), the special format that will be
damaged and in the end so the client does not understand the longer format of
the data it receives. Parsing process failed and then going over munculah error.


Why it occurs http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx#b!

Solution http://siderite.blogspot.com/2007/02/aspnet-ajax-and-responsewrite-or.html



protected override void Render(HtmlTextWriter writer)
{

//base.Render(writer);

// render to my own text writer

HtmlTextWriter tw = new HtmlTextWriter(new StringWriter());
base.Render(tw);

/* Code 1 */
//if ( Page != null )
//{
// Page.VerifyRenderingInServerForm ( this );
//}

//base.Render ( tw );
/* Code 1 */

/* Code 2 */

// base.Render(tw); // Code 2 is replaced by code 1

/* Code 2 */

// get the Rendered content of the page

string content = tw.InnerWriter.ToString();

content = RecursiveTranslateAjax(content);
writer.Write(content);
}

private static string RecursiveTranslateAjax(string content)
{

// look for the basic Ajax response syntax

Regex reg = new Regex ( @"^(\d+)\|[^\|]*\|[^\|]*\|", RegexOptions.Singleline );
Match m = reg.Match ( content );

// if found, search deeper, by taking

// into account the length of the html text

if ( m.Success )
{

// custom method to get an integer value

int length = Int ( m.Groups [1] );

reg = new Regex ( @"^(\d+)(\|[^\|]*\|[^\|]*\|)(.{" + length + @"})\|",

RegexOptions.Singleline );

m = reg.Match ( content );

if ( m.Success )
{

string trans = Translate ( m.Groups [3].Value );
return trans.Length + m.Groups [2].Value + trans + "|" +
RecursiveTranslateAjax ( content.Substring ( m.Length ) );
}
}

// if not Ajax, just translate everything,

// it must be a normal PostBack or a string of some sort.

return Translate ( content );
}

private static bool IsNumericVariable(object o)
{
return (o is byte || o is int || o is long || o is float || o is double || o is decimal);
}

public static int Int(object o)
{

if ( o == null ) return 0;

/* const string pattern = "(^[-+]?\\d+(,?\\d*)*\\.?\\d*([Ee][-+]\\d*)?$)|(^[-+]?\\d?(,?\\d*)*\\.\\d+([Ee][-+]\\d*)?$)";
Match numberic = Regex.Match ( o.ToString (), pattern );

// Match numberic = Regex.Match(o.ToString(), "(-\\d+|\\d+)");

// if (IsNumericVariable(o)) return (int)CastDouble(o);

// if (numberic.Success) return (int)CastDouble(o);


if (numberic.Success) return Convert.ToInt32 ( ( (Capture) ( o ) ).Value );
*/
if (IsNumericVariable(o)) return Convert.ToInt32(((Capture)(o)).Value);


string s = o.ToString ();

if ( s == "" ) return 0;

Match m = Regex.Match ( s, "(-\\d+|\\d+)" );

if ( m.Success )

try
{

return Int32.Parse ( m.Groups [0].Value );

}
catch
{

}

return 0;

}

// this method only fixes the weird characters

// but you can put here any string change you would like

// like search and replace some words.

private static string Translate(string content)
{

// Html code all chars that are not ASCII, thus getting rid of strange or Unicode characters

StringBuilder sb = new StringBuilder ();

for ( int c = 0; c <> 127 ) sb.Append ( "&#" + ( (int) content [c] ) + ";" );

else sb.Append ( content [c] );

}

return sb.ToString ();

}


Tuesday, November 25, 2008

RPX - Intermediater between OpenID providers and the WebSite Hosters

We can get OpenId provies by adding like this in our web site

<iframe src="https://asp-tech-blogspot.rpxnow.com/openid/embed?token_url=http://asp-tech.blogspot.com/" style="width: 400px; height: 240px;" scrolling="no" frameborder="no">&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;br&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;</iframe>


Look at this for more detais https://rpxnow.com/


Monday, November 24, 2008

Journey Planner

Journey Planner

Thursday, November 20, 2008

Background image on button not showing in IE

This render the image on the background of the Input tag in FF but not in IE

<input class="button" value="Login" style="" type="submit"/>



I just had to add a border to the style containing my background image.
The image is ignored by IE without the border.
I don't want to see a border,
but fortunately, including a 0px border still works.
I simply changed

border-style: none;

to

border: 0px solid #FFFFFF;

<input class="button" value="Login"
style="border: 0px solid rgb(255, 255, 255);
background-image:
url(Images/button_bg.png);
background-repeat: repeat-x; display: block;" type="submit"/>



Saturday, November 15, 2008

Web Method


If our return type is DataSet then we will get this error message

A circular reference was detected while serializing an object of
type "System.goblaization.CultureInfo"

setting response format to XML

[System.Web.Script.Services.ScriptMethod(ResponseFormat=
System.Web.Script.Services.ResponseFormat.Xml)]
public DataSet Get()
{
DataSet ds = new DataSet();

return ds;
}


Thursday, November 6, 2008

Difference between NULL and (Empty or ' ')

DECLARE @A VARCHAR(10)
DECLARE @B VARCHAR(10)
DECLARE @C VARCHAR(10)

BEGIN
 --Step:1
        SELECT ISNULL(@A , ' ')  -- RETURNS ' '
        SELECT ISNULL(@A , NULL) -- RETURNS NULL
        SELECT ISNULL(@A , @B) -- RETURNS NULL
        
        --Step:2
        SET @A = '' --Since we have assigned some value which is not null
        SELECT ISNULL(@A , ' ')  -- RETURNS ''
        SELECT ISNULL(@A , NULL) -- RETURNS ''
        SELECT ISNULL(@A , @B) -- RETURNS ''
        
        --Step:3
 SET @A = NULL--Which is same as the Step:1
        SELECT ISNULL(@A , ' ')  -- RETURNS ''
        SELECT ISNULL(@A , NULL) -- RETURNS NULL
        SELECT ISNULL(@A , @B) -- RETURNS NULL
        
        --Step:4
        SET @B = ' '
        SELECT ISNULL(@B , ' ')  -- RETURNS ' '
        SELECT ISNULL(@B , NULL) -- RETURNS ' '
        SELECT ISNULL(@B , @C)   -- RETURNS ' '
        SELECT ISNULL(@C , @B)   -- RETURNS ' '
        SELECT ISNULL(@B , @A)   -- RETURNS ' '
        
        --Step:5
        SET @A = '1'
        SELECT ISNULL(@B , @A) -- RETURNS ' '
        SELECT ISNULL(@A , @B) -- RETURNS 1
        SELECT ISNULL(@C , @A) -- RETURNS 1
END