database connection
Hello,
I have made a module (with Radrotator) that get a picturs (from a SQLEXPRESS database) and display it,that work greate,so now i would like to integrate it (like a widget) to used it in my sitesinity 5 project but i get an error about the string connection,where do I défine it ?
The error is , and how can i resolve this problem ?
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL: |
Hey Med,
SQL Connections are stored in the DataConfig.config file. You can find it by going from the root folder of your project to App_Data/Sitefinity/Configuration.
When you open the file, you'll find the default connection string for the Sitefinity database already there.
Jochem.
Thank you for the reply,
I attached the database when I created the project, and I added the connection string ("CantonConnectionString") in the file dataconfig.config but i get this error :
|
Hey Med,
Euhm if I'm not mistaking the <%$ is the culprit, I think it should be <%= instead so you'll get
ConnectionString="<%= ConnectionStrings:CantonConnectionString %>"
Hey Med,
Your post doesn't show up here but I received it in the email. The problem with the code is your trying to paste .aspx code into an .ascx. (an .aspx is a full page, a .ascx is just a snippet you 'paste into' a full page. So all the doctype/html/form/body etc needs to be removed)
<%@ Control Language=
"C#"
AutoEventWireup=
"true"
CodeBehind=
"WebUserControl1.ascx.cs"
Inherits=
"SitefinityWebApp.WebUserControl1"
%>
<
div
>
<
telerik:RadRotator
ID
=
"RadRotator1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
AppendDataBoundItems
=
"True"
>
<
ItemTemplate
>
<
asp:Image
ID
=
"Image1"
runat
=
"server"
ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Id", "Handler.ashx?Id=0") %>'/>
</
ItemTemplate
>
</
telerik:RadRotator
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%= ConnectionStrings:CantonConnectionString %>"
SelectCommand="SELECT [Id] FROM [ArtisteImageBlog]">
</
asp:SqlDataSource
>
</
div
>
hi Jochem and thanks a lot for your help,
Now I dont have any error but the RadRotator does not display the images,I dont know why ! I just fellow the same steps . I attach the pictures that show that .
Thankx again
Dear Med
I would use Fiddler2.com to see what is happening.What is tried to be loeaded and what's the error.
Markus
Hey Med,
With each step where getting closer no?
Since you're using Chrome as a browser you can right click one of the 'broken image' icons and click 'inspect element'. This will show you the rendered source of the html and might give a clue as to why the images aren't showing. (see screenshot 1)
Next to that you can click the 'resource tab' and reload the page. If you scroll up/down you'll see all individual files being loaded (or not). The ones Chrome couldn't load will show up in red and have a status of 404. (see screenshot 2)
When you hover over the name of that file, a tooltip will show you the exact URL it tried to load it from.
Hi Hochem, Makus Berchtold and thank you for your help,
The problem is that I follow the same steps (I just remplace the Web form by a web user control ) but it doesn't work ! the RadRotator doesn't display the picturs .
The website :
www.mediafire.com/
The widget :
www.mediafire.com/
Thank you again
Dear Med
Did you follow Jochems advice to see what is going on?
---------
What is the path to the missing images.
As an alternative to Jochems advice use fiddler2.com to see what is going on.
Markus
Hi Mukus Berchtold,
Yah of course, and I used Fiddler to,I have this error now :
403 Forbidden,
Hello,
I noticed that sitefinity change the Id,src and url of the images.
I dont know why, and how to fixe that !
And how can we do to make work on sitefinity a module that work greate on VS2010 ( a module that use a database)?
I add the 2 screenshot that show that.
Hop that the sitefinity admin help us to fixe that and progress and it w'll be usefull for many peoples who would like to used that .
Thank you
Hey Med,
Sorry I haven't been able to try out the widget myself yet, but it seems that since you're not referencing the handler.ashx with a full url, Sitefinity tries to attach the path to it.
Because the widget is in the /App_Data/ folder, you get the 403 error. I'm guessing if you make the image src="//Sitefinity/WebsiteTemplates/Theme01/WidgetTemplates/widget/Handler.ashx?Id=1" it should work. (Sitefinity automatically maps the /App_Data/Sitefinity to /Sitefinity).
Hi Jochem,
Thank you so mutch for your help.
I have change the Handler url in the widget.ascx and it doesn't work ( cause it dublicate the src url ) ,then I have put the widget files (handler.ashx , widget.ascx , ...) outside App_Data (in the
sitefinity root project ) so I have got a url picture that doesn't existe in sitefinity project folder (ProAd/essaiwidget23/Action/../../Handler.ashx).
I attache the pictur that explain that,
Thank you so mutch
Hi jochem,Markus,
Thank you so mutch for helping me.
The widget work,I have got a Cs0433 error and I have solve it by put the db connection file outsite App_Data folder.
Thankx again
Med
Hey Med,
Glad you got it working and sorry it took so long
Jochem