Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
i have small webmethod returning simple dataset from sql table...
this works if i set asp.net framework as 3.5 but after setting it to 2.0 its not working

i have done below mention code on default.aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>AutoComplete Box with jQuery</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css"
rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
SearchText();
});
function SearchText() {
alert('IN');
$(".autosuggest").autocomplete({


source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../Default.aspx/Mydata",
data: "{'username':'" + JSON.stringify(document.getElementById('txtSearch').value) + "'}",
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert(result);
}
});
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">


<label for="tbAuto">
Enter UserName:
</label>
<input type="text" id="txtSearch" class="autosuggest" />


</form>
</body>
</html>
Posted
Updated 4-May-15 10:07am
v4

1 solution

I will continue from your statement,
Quote:
this works if i set asp.net framework as 3.5 but after setting it to 2.0 its not working
You need to know that the version you are trying to refer to is .NET framework version and not the ASP.NET version. ASP.NET requires .NET framework to run over, the framework version is counted of .NET framework; although do not forget ASP.NET also has versions[^].

What you missed is that you required to use .NET framework 3.5. You changed the target framework required, you require 2.0 installed on your machine for the application to work now. So there are possibly two solutions.


  1. Revert these changes.
  2. Install .NET framework 2.0 so that ASP.NET can target the required framework on the machine.


If you perform the above tasks your application will again run. This is also just an ASP.NET Web Forms page, you are required to mention the error you are getting.
 
Share this answer
 
Comments
HimenDev 4-May-15 15:27pm    
@Afzaal:
i have got an error "[object XMLHttpRequest]" as an alert which i set in above code.
also i change my target framework 2.0 intentionally, if i set my target framework as 3.5 then its working fine.
now this is issue regarding serialization and i dont understand this funda.
because in .net 3.5 it will directly convert your responce but here you have to do some xml parsing...
also i found that in this issue i have to modify my web.config file too..
i dont understand that stuff...any help will be usuful.
Afzaal Ahmad Zeeshan 4-May-15 15:37pm    
That is because .NET framework 3.5 was better than 2.

Secondly, [object XMLHttpRequest] message should be generated by JavaScript indicating that you have alert-ed the user with the (ajax request) object itself and not with the value.

Yes, you have to change the settings back to target the application in a .NET framework 3.5 version.
HimenDev 4-May-15 15:41pm    
i dont want to change my framework to 3.5
i want this to be done with using framework 2.0
This is possible but i just cant not understand xml parsing or web.config setting for this issue.... but i m so sure that this is possible with 2.0 framework
Afzaal Ahmad Zeeshan 4-May-15 16:18pm    
Yes this is possible. You might consider reading documentation for .NET framework 2.0.
HimenDev 5-May-15 0:47am    
Sorry brother, its not helping ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900