Showing posts with label own. Show all posts
Showing posts with label own. Show all posts

Monday, March 26, 2012

Ajax toolkit dragdropmanager

Hello, I'm using Ajax toolkit in my project.

I have written own extender for drag and drop procedure.

Everything is fine, except that images that is located in target control doesn't fire onlick event.

Seems like, dragdropmanager disable this event on page load. Any workarounds?

thanks in advance.

Hi,

the DragDropManager doesn't disable any events of DOM elements. Could you explain in more detail your scenario? Are the images the draggable items?

Wednesday, March 21, 2012

AJAX Slideshow using a dynamic Webservice to display images

Hi there,

I have just managed to get the example slideshow working within my own project. I would like to take it a step further by using a database and a folder within my site to display selected images.

Let me try explain.

For the ease of explaining things lets say a user adds their UserID into a textbox and pressing a button. I then have a select statement that gets all the image names for that user. The webmethod then uses those names from the SELECT statement to loop through the folder which contains the images and then displays the images within the slideshow.

The current web method looks like this

public static AjaxControlToolkit.Slide[] GetSlides() {return new AjaxControlToolkit.Slide[] {new AjaxControlToolkit.Slide("/images/Blue hills.jpg","Blue Hills","Go Blue"),new AjaxControlToolkit.Slide("/images/Sunset.jpg","Sunset","Setting sun"),new AjaxControlToolkit.Slide("/images/Winter.jpg","Winter","Wintery..."),new AjaxControlToolkit.Slide("/images/Water lilies.jpg","Water lillies","Lillies in the water"),new AjaxControlToolkit.Slide("/images/VerticalPicture.jpg","Sedona","Portrait style picture")}; }

As you can see everything is hard coded with the images and the comments and names.

Has anyone done something like this before?

Any advise or tips would be really helpful.

Thanks Shane

Check out forum posthttp://forums.asp.net/thread/1608950.aspx. It talks about passing in user context to retrieve images from the database.

AJAX slideshow gives me error Acme.SubAcme.ConvertMeTypeConverter cannot be found.

Hi there,

I have copied the slideshow example into my own project.
So I now have a folder called SlideShow. I copied the images folder over and also SlideShow.aspx,slide.cs,slideshowbehaviour.js,slideshowdesigner.cs,slideshowextender.cs

When I try opening the page I get a large popup box displaying the following error message.

--------
Windows Internet Explorer
--------
The server method 'GetSlides' failed with the following error: <html>

<head>

<title>Type: 'Acme.SubAcme.ConvertMeTypeConverter' cannot be found.</title>

<style>

body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}

p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}

b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}

H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }

H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }

pre {font-family:"Lucida Console";font-size: .9em}

.marker {font-weight: bold; color: black;text-decoration: none;}

.version {color: gray;}

.error {margin-bottom: 10px;}

.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }

</style>

</head>

<body bgcolor="white">

<span><H1>Server Error in '/AjaxShaneSite' Application.<hr width=100% size=1 color=silver></H1>

<h2> <i>Type: 'Acme.SubAcme.ConvertMeTypeConverter' cannot be found.</i> </h2></span>

<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">

<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

<br><br>

<b> Exception Details: </b>System.ArgumentException: Type: 'Acme.SubAcme.ConvertMeTypeConverter' cannot be found.<br><br>

<b>Source Error:</b> <br><br>

<table width=100% bgcolor="#ffffcc">

<tr>

<td>

<code>

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified usin…
--------
OK
--------

Does anyone know what I have done wrong?

Thanks for your help.

Shane

In your web.config have you uncommented the json serialization section? You will need to add a real converter in that section. This, Acme.SubAcme.ConvertMeTypeConverter, is just a "howto" placeholder.

<

system.web.extensions>

<

scripting>

<

webServices>

<!--

Uncomment this line to customize maxJsonLength and add a custom converter-->

<!--

<jsonSerialization maxJsonLength="500">

<converters>

<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>

</converters>

</jsonSerialization>

-->

<!--

Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate.-->

<!--

<authenticationService enabled="true" requireSSL = "true|false"/>

-->

<!--

Uncomment these lines to enable the profile service. To allow profile properties to be retrieved

and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and

writeAccessProperties attributes.

-->

<!--

<profileService enabled="true"

readAccessProperties="propertyname1,propertyname2"

writeAccessProperties="propertyname1,propertyname2" />

-->

</

webServices>

<!--

<scriptResourceHandler enableCompression="true" enableCaching="true" />

-->

</

scripting>

</

system.web.extensions>

Hi Kirtid

Yip I have uncommented that line. I copied over the webconfig from the example site into my own site.

This is the webconfig. I am really new to .NET & AJAX so I am not sure how what I need to do to add a real converter in that section

Thanks for your help

Shane

 <configuration> <configSections> <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/> <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"> <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/> <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/> <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/> </sectionGroup> </sectionGroup> </sectionGroup> </configSections> <system.web> <trust level="Medium"/> <pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </controls> </pages><!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="true"> <assemblies> <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies> </compilation> <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/> </httpHandlers> <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </httpModules> <siteMap defaultProvider="SamplesSiteMap"> <providers> <add name="SamplesSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Web.sitemap"/><!-- <add name="WalkthroughsSiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Walkthroughs.sitemap"/> --> </providers> </siteMap> <globalization culture="en-us" uiCulture="en"/> </system.web> <system.web.extensions> <scripting> <webServices><!-- Uncomment this line to customize maxJsonLength and add a custom converter --> <jsonSerialization maxJsonLength="50000"> <converters> <add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/> </converters> </jsonSerialization><!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. --> <!-- <authenticationService enabled="true" requireSSL = "true|false"/> --> <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. --> <!-- <profileService enabled="true" readAccessProperties="propertyname1,propertyname2" writeAccessProperties="propertyname1,propertyname2" /> --> </webServices><!-- <scriptResourceHandler enableCompression="true" enableCaching="true" /> --> </scripting> </system.web.extensions> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </handlers> </system.webServer></configuration>

Shane,

You can use the web.config from the toolkit sample website for your stuff. We have it commented out in that file. Looks like you do not need to worry about Converters and you can safely keep it commented out. If you need more information you can take a look at some documentation onconverters.

Kirti


Hi again,

Sorrry if im sounding very simple here but I don't understand :( I have searched through the example site and there is only 1 reference toAcme.SubAcme.ConvertMeTypeConverter which is the web.config which is the same as mine.

However I get this popup.

Do I need to add this into the page load event?

// Get the Web application configuration.
System.Configuration.Configuration configuration =
WebConfigurationManager.OpenWebConfiguration("/aspnetTest");

// Get the external JSON section.
ScriptingJsonSerializationSection jsonSection =
(ScriptingJsonSerializationSection)configuration.GetSection(
"system.web.extensions/scripting/webServices/jsonSerialization");

//Get the converters collection.
ConvertersCollection converters =
jsonSection.Converters;

if ((converters != null) && converters.Count > 0)
{
// Get the first registered converter.
Converter converterElement = converters[0];
}


You should just comment out that section. You do not need it if you are not dealing with Converters. Acme.SubAcme.ConvertMeTypeConverter is just a dummy placeholder that is actually commented out in the atlas web.config and in our sample website web.config as well. It is a "how-to" add a converters section to your web.config file sample. We recommend that you reuse the sample website web.config for starters.

Thank-you I do feel silly now.

This brings me to my next question so I think I will start a new thread.

Thanks again.

Shane