Showing posts with label downloaded. Show all posts
Showing posts with label downloaded. Show all posts

Wednesday, March 28, 2012

ajax beta 2, treenode collapsing?

Greetings,

I downloaded and im using the ajax tookit 2. I have a problem with putting a treeview in a datagrid and getting it to work properly. I found other threads on this issue (mainly when navagating to other pages), but none of them seemed to address (or at least address and provide a solution for) the problem I have. Here is the issue.

I have a treeview with nodes that post back. On the post back, I simply collapse the node if its expanded and vice versa. It works good outside of an updatepanel, but when I put it inside an updatepanel, the expanded state does not save. Is there a simple solution? Is there someway I can call the javascript that the +/- control uses (so I dont have to expand/collapse in the code)?

Heres some code to show you my simple example

<%

@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.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"/><div> <asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate> <br/><asp:TreeViewID="TreeView"runat="server"OnSelectedNodeChanged="select2"><Nodes><asp:TreeNodeText="New Node1"Value="New Node11"Expanded="False"><asp:TreeNodeText="New Node12"Value="New Node12"></asp:TreeNode></asp:TreeNode><asp:TreeNodeText="New Node2"Value="New Node2"Expanded="False"><asp:TreeNodeText="New Node21"Value="New Node21"><asp:TreeNodeText="New Node22"Value="New Node23"></asp:TreeNode></asp:TreeNode></asp:TreeNode><asp:TreeNodeText="New Node31"Value="New Node31"Expanded="False"><asp:TreeNodeText="New Node32"Value="New Node32"><asp:TreeNodeText="New Node33"Value="New Node33"></asp:TreeNode></asp:TreeNode></asp:TreeNode><asp:TreeNodeText="New Node4"Value="New Node4"Expanded="False"></asp:TreeNode><asp:TreeNodeText="New Node5"Value="New Node5"Expanded="False"></asp:TreeNode></Nodes></asp:TreeView><br/> </ContentTemplate></asp:UpdatePanel></div> <br/><br/></form>

</

body>

</

html>

-------------------

using

System;

using

System.Data;

using

System.Configuration;

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

partialclass_Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid select2(object sender,EventArgs e)

{

TreeNode selected = TreeView.SelectedNode;if ((bool)selected.Expanded)

{

selected.Collapse();

}

else

{

selected.Expand();

}

selected.Selected =

false;

}

}

While we work closely with the ASP.NET AJAX team when developing the Toolkit, they're the real experts on general ASP.NET AJAX issues. Your problem doesn't seem to be directly related to the Toolkit, so we'd appreciate if you considered posting to one of theother newsgroups such asAJAX Discussion and Suggestions. Your post will be more helpful to others looking for similar advice if it's in the right place. Thank you!

Ajax beta 2 is not working with iis 6

i downloaded the ajax beta 2 from ajax.asp.net and install it in the production server which has iis 6, and i publish the site which is running well in the development server, ajax is not working any more, with any pages action they page refresh itself, i dont know what's is going on!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

OK!Have you deployment it?
Can you actually respond with actual errors it would help US help you..

Hi,

As my knowledge it wills works without any errors,

Please go through your code, you might be did mistakes in the code.

Or can you send the code then only forum can help you.

Maximum problem with your code only..

Pradeep Kumar Bura


the pages dosn't display any error message, the situation is that the page has update panel , so when user click on a search button it should display the result inside the update panel without refreshing the page, and thiss happen in the development server, but on the production page the same page server when user click on the search button, the pages is refreshed :(


Hi,

Have you checked event log for errors?

Pradeep Kumar Bura


Hi. I had a similar problem. After Installation on productive server, the sites were'nt executable because the webserver didn't found one the assemblies which will be installed while the extension installation (Microsoft.Web.Extension and Microsoft.Web.Extension.Design).

I installed and registered the assemblies whith gacutil and the aplication was running again.


I've deployed AJAX Beta 2 to four servers running IIS6. On two of the four I ran into the same issue that Michael63 describes. For me Microsoft.Web.Extension.Design was not added to the GAC. You can either register it in the GAC or you can copy it to your site's bin directory. I did the GAC way on one server and copied it into the bin folder on another - both work fine. The other thing you may want to check is that a new entry in the web.config is required. Check out the readme included with the installations for instructions.
Your site has to be running in full trust mode to be able to run the dlls in the bin folder.

i did that, and i checked that the assemply is added to the GAC , but still the site working very well in dvelopment server, but on production server, it's not the only differnce is that the development server has atlas component before but i uninstalled it before install ajax, but it was the only differnce


http://forums.asp.net/thread/1485037.aspx
follow this threadhttp://forums.asp.net/thread/1485037.aspx

AJAX Beta 1 error

Hello,

I just downloaded AJAX Beta 1, I have not used any of the previous Atlas version and this is my first stab at Microsoft's AJAX, on my dev machine and on the production machine I consistently get this same error message when a postback should occur from a dropdownlist:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed"


I have search high and low on these forums and I can't seem to find a resolution to this. Here is the code on my aspx page that shows the scriptmanager and updatepanel:

<asp:ScriptManager id="scmAddItem" runat="server" EnablePartialRendering="True" />
<asp:UpdatePanel id="pnlCategory" runat="server" UpdateMode="Conditional" RenderMode="Inline">
<ContentTemplate>
Item Base Category : <asp:DropDownList ID="cmbItemCategory" AutoPostBack="true" OnSelectedIndexChanged="cmbItemCategory_IndexChanged" runat="server"></asp:DropDownList><br />
Choose Sub Category <asp:DropDownList ID="cmbSubCategory" runat="server"></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>

As you can see, I have one dropdown, that when changed should fire the OnSelectedIndexChanged event, but this doesnt seem to happen, I just consistently get the above error message. I copied the sample web.config and placed the dll's in the bin folder with no results.

Anyone come across this before? Any help would be greatly appreciated.

Thanks

Sean

This weekend many people have problems with ASP.NET 2.0 AJAX, thanks Scott Guthrie for releasing something on Friday!

Do you have the problem in every page or just one? Because looks like the project is not set up properly. Got a post about setting up the Atlas projects, however I need to see if still applies to the new ASP.NET 2.0 AJAX (name to long)

http://alpascual.com/blog/al/archive/2006/07/12/Setting-up-Atlas-to-existing-Web-Projects-without-using-the-template-_2800_-Visual-Studio-2005-_2900_-.aspx

Please, let me know if that helps you, if not, I'll update the article with a new set up for ASP.NET 2.0 AJAX ( What about just calling it Atlas?)


Ok,

This is what I have found out so far, If I create a new page, and put my updatepanel in it, it updates properly as expected.

It seems to only be a problem with this one page in peticular where I have a series of complex steps setup, I was trying to add ajax functionality to it and I can't seem to get around the error message I am receiving, i am thinking perhaps it is something with ViewState?

I am doing some more testing now, and I will report back when I find the cause.

Quite strange.


I dont know if it is right solution. I had same problem. If you look at your rendered page so there is in JS method forexample
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tctl00$cphCenter$UpdatePanel1'], [], [], 90); , but no tctl00$cphCenter$UpdatePanel1 object isn't on page. So when i am rendering the page i replace tctl00$cphCenter$UpdatePanel1 with right id ctl00$cphCenter$UpdatePanel1 without t at the begining and there is no error no more.
 
Hope this helps. If not so sorry. 

Well it seems that that T is there rightly. I have read MicrosoftAjaxWebForms.js and found it but for the moment i don't understand it. So sorry

Monday, March 26, 2012

Ajax AutoComplete with database, not working

Hello,

I am interested in implementing a search box which gives suggestions as you type. So, I downloaded the AjaxControlToolKit source code, I compiled the solution in VS 2005, and it is OK.

Then I modified the [WebMethod] public string[] GetCompletionList(string prefixText, int count) in an attempt to get the string array from a User table in my database.

I don't quite understand this WebMethod. for example,what is prefixText? My modified code is as follows.

1 [WebMethod]2public string[] GetCompletionList(string prefixText,int count)3 {4if (count == 0)5 {6 count = 10;7 }89if (prefixText.Equals("xyz"))10 {11return new string[0];12 }1314string connectionString ="localhost;Initial Catalog=myDatabase; User Id=myUserID; Password=topSecrect";15 SqlConnection sqlConnection =new SqlConnection(connectionString);16 sqlConnection.Open();17 SqlCommand sqlCommand =new SqlCommand("SELECT LASTNAME + ', ' + FIRSTNAME FROM USER AS FULLNAME ORDER BY LASTNAME", sqlConnection);18 SqlDataReader sdr = sqlCommand.ExecuteReader();1920 ArrayList fullNames =new ArrayList(count);2122while (sdr.Read())23 {24if (!sdr.IsDBNull(0))25 {26char c1 = (char)sdr.GetString(0)[0];27char c2 = (char)sdr.GetString(0)[1];28char c3 = (char)sdr.GetString(0)[2];29 fullNames.Add(prefixText + c1 + c2 + c3);30 }3132 }33return (string[])fullNames.ToArray(typeof(string));34 }

Please note that I do not quite understand the part in the for loop as in the original source code shown in blue below. So I am only mimicking the code.

// ArrayList items = new ArrayList(count);
// Random random = new Random();
// for (int i = 0; i < count; i++)
// {
// char c1 = (char)random.Next(65, 90);
// char c2 = (char)random.Next(97, 122);
// char c3 = (char)random.Next(97, 122);

// items.Add(prefixText + c1 + c2 + c3);
// }

Also please note, that the compilation of the solution with the modified code passed, and I can check out http://localhost:7870/ToolkitTests/AutoComplete.aspx just fine, but when I type in the first textbox of this AutoComplete.aspx page, no suggestions show up. The second textbox still works as usual.

The Sql query and connection string are both fine. I ran it in some other applications, they work without a problem.

Any hint is highly appreciated. Thanks.

The prefixText field are the characters that have been typed and are being queried, the count is the max number of records to return then updated with the number of records returned.

The Random... etc code, was just a way for the demo application to generate random data without attaching a database.


jguadagno:

The prefixText field are the characters that have been typed and are being queried, the count is the max number of records to return then updated with the number of records returned.

The Random... etc code, was just a way for the demo application to generate random data without attaching a database.

OK, thanks. My guess about the prefText argument was right. But, what's wrong with my modified code, which attempts to get the suggestions from the database?


Is there a way to get the suggestion list from a database? No one knows?


You have the code in the GetCompletionList. Is it not working. Remember the prefixText are the letters that the text box control has so far. So if the is a Country drop down list as user type U, the prefixText should get a U and you have to return a list of your options that start with U.


OK, I found a sample code at

http://forums.asp.net/p/1126189/1772074.aspx#1772074

By J. Shen, In order to test the dynamic SQL, I created a regular web application (NOT web service!) I just copied the part of the aforementioned code which gets the suggestions from the DB and modified like so:

public string[] GetCompletionList(string prefixText, int count)
{
if (count == 0)
{
count = 10;
}

if (prefixText.Equals("xyz"))
{
return new string[0];
}

string connectionString = "Data Source=localhost;Initial Catalog=mydatabase; User Id=myUserID; Password=TopSecret";
SqlConnection sqlConnection = new SqlConnection(connectionString);

SqlCommand sqlCommand = new SqlCommand
("SELECT TOP @.nrows LASTNAME " +
"FROM v_USER " +
"WHERE LASTNAME LIKE @.term " +
"ORDER BY LASTNAME", sqlConnection);
sqlCommand.Parameters.AddWithValue("@.nrows", count);
sqlCommand.Parameters.AddWithValue("@.term", prefixText + "%");

List<string> suggestions = new List<string>();
sqlConnection.Open();

SqlDataReader sdr = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

while (sdr.Read())
{
suggestions.Add(sdr[0].ToString());
}

sqlConnection.Close();
sdr.Close();

return suggestions.ToArray();

}

As you see, except the SQL, it's the same as that of J. Shen's. I call this method in Page_Load like so:

protected void Page_Load(object sender, EventArgs e)
{

string[] s = GetCompletionList("Joh", 10);
Response.Write(s.Length);
}

When I run the Web application. I always get this error:

Exception Details:System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '@.nrows'.

I am using SQL Server 2000, and obviously, the SQL query syntax isn't accepted by Sql Server 2000. I cannot figure out what's wrong with it. I am new to dynamic sql.

Any hint? Thanks.


The problem is with TOP @.nrows ... You can not have a variable for that. You can build the string prior to

string sql ="SELECT TOP " + count.ToString() +"LASTNAME FROM v_USER ";string sql +=" WHERE LASTNAME LIKE @.term ORDER BY LASTNAME ";SqlCommand sqlCommand =new SqlCommand(sql, sqlConnection);


Thank you very much, Joseph. That was the problem. It's working now. The sample code given by J. Shen completely misled me. I did not cast any doubt on his code because I took it for granted that it was a working sample.


I am glad it worked. Please mark it as "Answered" so that others will know the solution.


Hi All,

I have been trying to replicate this post in VB.net and I "think" I am almost there. I am stuck on a couple of small pieces and I'm begging for help. I have been trying to get the AJAX autocomplete to work off of a SQL database for many hours before I ran into this post which seems promising. I feel I'm at my ends.

I'm having trouble with the following lines, I'm tried to figure out what the code was trying to do but this is what I could come up with and its not working:
----------------------------------
Dim suggestionsAs ListItemCollection =New ListItemCollection(OfString)

While (reader.Read())
suggestions.Add(reader[0].ToString())
EndWhile

Return suggestions.ToArray
----------------------------------

Thanks in advance, I truely appreciate it.
Tim

Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports System.Data.Sql
Imports System.Data.SqlClient

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _

PublicClass AutoComplete
Inherits System.Web.Services.WebService

<WebMethod()> _

PublicFunction GetCompletionList(ByVal prefixTextAsString,ByVal countAsInteger)AsString()

If (count = 0)Then
count = 10
EndIf

Dim connAs SqlConnection
Dim commAs SqlCommand
Dim readerAs SqlDataReader
Dim connectionstringAsString = ConfigurationManager.ConnectionStrings("Magic").ConnectionString
Dim sqlAsString ="SELECT TOP " + count.ToString() +"LASTNAME FROM v_USER "

sql +=" WHERE LASTNAME LIKE @.term ORDER BY LASTNAME "

conn =New SqlConnection(connectionstring)
comm =New SqlCommand(sql, conn)
comm.Parameters.AddWithValue("@.nrows", count)
comm.Parameters.AddWithValue("@.term", prefixText +"%")

Dim suggestionsAs ListItemCollection =New ListItemCollection(OfString)

conn.Open()
reader = comm.ExecuteReader(System.Data.CommandBehavior.CloseConnection

While (reader.Read())
suggestions.Add(reader[0].ToString())
EndWhile

conn.Close()
reader.Close()

Return suggestions.ToArray

EndFunction
EndClass


With comments

''' Creates a list array

Dim suggestionsAs ListItemCollection =New ListItemCollection(OfString)

''' Opens the connection

conn.Open()

''' Creates a data reader
reader = comm.ExecuteReader(System.Data.CommandBehavior.CloseConnection

''' Loops through the data reader

While (reader.Read())

''' Adds the first column to the suggestions array

''' note: in VB this should read
suggestions.Add(reader(0).ToString())
EndWhile

''' close the objects

conn.Close()
reader.Close()

''' return the suggestion

Return suggestions.ToArray


Almost there...

I have everything compiling correctly, Visual Studio 05 isn't giving me any error messages but when I type in the textbox nothing happens. It must be linked incorrectly. I know the SQL statement works correctly because I ran it in Query Analyzer, and I know the connection string works because I have other data pulling so I think the function GetCompletionList isn't being passed any parameters for it to return a result.

If someone could explain the mapping so I can go back and verify everything on my end that would be good. Currently I have the autocompleteextender controlID set to my textbox. Other than that, the AJAX website knows to use the AutoComplete.asmx which then points to the App_Code/Autocomplete.vb right? Or does this have to be set manually or something.

Idea's?
Thanks!
Tim


The autocompleteextender needs to be configured like this

<ajaxToolkit:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="myTextBox" ServiceMethod="GetCompletionList" ServicePath="AutoComplete.asmx" MinimumPrefixLength="2" CompletionInterval="1000" EnableCaching="true" CompletionSetCount="20" CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem" CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" DelimiterCharacters=";, :"> <Animations> <OnShow> ... </OnShow> <OnHide> ... </OnHide> </Animations></ajaxToolkit:AutoCompleteExtender>
Note, the ServiceMethod and ServicePath properties. They need to be pointed to whereever your AutoComplete is.

ajax autocomplete text

Hi,

I downloaded ajax 1.0 beta 2 and the controls toolkit.

I want to make an autocomplete textbox that while typing letters in it,

a dropdownlist is opened under it and filled by ajax with every new letter typed in the textbox.

When choosing a value in the ddl, it disappears and the selected value inserted into the textbox.

I saw such examples in atlas, but I prefer to use ajax 1.0 , since I relized that this is the recommended product.

Is there any control in the controls toolkit for that ? Did somebody here tried it before ?

Thanks a lot !

AutoCompleteExtender currently lives in the Futures CTP:http://www.microsoft.com/downloads/details.aspx?FamilyId=29B6B62B-A25A-498D-AA14-90B68CF2E392&displaylang=en

Saturday, March 24, 2012

AJAX and Toolkit

Last week I downloaded and installed AJAX and the associated toolkit viaASPAJAXExtSetup.msi andAjaxControlToolkit.zip respectively.

When I open thetoolkit.sln file in VS2005, I get a flock of error messages, most notable of which are messages to the effect that the app is unable to find the System.Web.Extensions.dll and System.Web.Extensions.Design.dll files.

In looking at the installed files I noticed the following differences between the AJAX Extensions files and the Toolkit Files:

o AJAX Extensions inC>Program Files>Microsoft ASP.Net>ASP.Net 2.0 AJAX Extensions>v1.0.61025 folder contains aweb.config file that includes numerous "microsoft.web" and "Microsoft.Web.Extensions" entries.

o AtlasControlToolkit files in C>Program Files>Microsoft ASP.Net, the resultant files also containweb.config files: One in each of the "SampleWebSite", "ToolkitTests", and "ToolkitWebsiteTemplate" sub-folders. Each of these threeweb.config files include numerous "system.web" and "System.Web.Extension" entries.

I assume that theSystem.Web.xxx is the appropriate syntax.

Is there possibly a newer version of theASPAJAXExtSetup.msifile that synchronizes the syntax between these two apps?

Is there something else that I may have missed?

(I had previously been using ATLAS: I uninstalled the ATLAS app, and deleted the toolkit folder before I installed teh AJAX apps)

Never mind.

I downloadedASPAJAXExtSetup.msi againand the toolbox now works OK.

All of the config files now match each other.

Wednesday, March 21, 2012

AJAX and formview

I downloaded the tool kit, but I am not sure which "example" I want to use. On my development web site:http://ptkvb.delfraisse.com, I have a formview to display "programs". Right now it has 1, 2 and 3 for the different programs. The problem is the post back. Would AJAX be a solution for me? Should I use formviews at all? I would like to auto switch to each of them every 30 seconds as well. I also would like to change the buttons on the bottom to "Prev * *(*) * * Next" type style (as displayed on this idea graphic:http://delfraisse.com/external/ptk/ptk-default.gif).

Thanks for your time.

Hi,

I made a sample according to your requirement with pure javascript, please try it:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void Page_Load(object sender, EventArgs e) { } </script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Untitled Page</title><script language="javascript" type="text/javascript">// <!CDATA[var index = 0;var projects = new Array();function pageLoad() { projects[0]=$get("Panel1"); projects[1]=$get("Panel2"); projects[2]=$get("Panel3"); displayProject(); window.setInterval(autoIncrease, 1000);}function Button1_onclick() { --index; displayProject();}function Button2_onclick() { ++index; displayProject();}function autoIncrease() { ++index; displayProject();}function displayProject() { for(var i=0; i projects[i].style.display ="none"; index = index%3; projects[index].style.display = "";}// ]]></script></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px"> Project 1</asp:Panel> <asp:Panel ID="Panel2" runat="server" Height="50px" Width="125px"> Project 2</asp:Panel> <asp:Panel ID="Panel3" runat="server" Height="50px" Width="125px"> Project 3</asp:Panel> <input id="Button1" type="button" value="Previous" onclick="return Button1_onclick()" /> <input id="Button2" type="button" value="Next" onclick="return Button2_onclick()" /> </form></body></html>

That only shows three projects. I need it to pull from the database and pull as many projects are in there. Right now my post back script is pulling from the database, that way I can add a project with a form or directly in the database.


The sample is mainly used to demonstrate how to use javascript to achieve your requirements, you may create panels and javascript dynamically according to the number of records in database.

AJAX Accordian - Resizing browser window hides all accordian panes.

Hi

(Downloaded Yesterday so all "current" / IE 7.0)

When i resize my IE 7.0 browser window containing an accordian control; The selected accordian pane is retracted/hidden. I then have to reclick a header in order to get the pane visibility back.
Is this a bug or have i not set a "certain" property?

Thanks

Richard

This is a known issue ( see posthttp://forums.asp.net/thread/1411709.aspx ) and has been planned for the next release of toolkit (expected release 28 feb)