Skip to content Skip to sidebar Skip to footer

How To Pass Html Tags To A Webmethod?

I'm trying to pass a parameter containing html tags as its value to a webmethod. But it seems not working and i'm only getting the error. Is that possible to do so. Can you suggest

Solution 1:

You should URL Encode on the client side and decode on the client side. essentially it changes "<" to "<".

Solution 2:

Perhaps a more stable and safer solution would be to base64 the data before it is sent? Base 64 will convert the entire string to a strict set of a-zA-Z0-9 and an equals sign. In ASP you can base64 using this: http://www.freevbcode.com/ShowCode.asp?ID=5248

// This code was written by Tyler Akins and has been placed in the// public domain.  It would be nice if you left this header intact.// Base64 code from Tyler Akins -- http://rumkin.comvar keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

functionencode64(input) {
    var output = newStringMaker();
    var chr1, chr2, chr3;
    var enc1, enc2, enc3, enc4;
    var i = 0;

    while (i < input.length) {
        chr1 = input.charCodeAt(i++);
        chr2 = input.charCodeAt(i++);
        chr3 = input.charCodeAt(i++);

        enc1 = chr1 >> 2;
        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
        enc4 = chr3 & 63;

        if (isNaN(chr2)) {
            enc3 = enc4 = 64;
        } elseif (isNaN(chr3)) {
            enc4 = 64;
        }

        output.append(keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4));
   }

   return output.toString();
}

Post a Comment for "How To Pass Html Tags To A Webmethod?"