Code target issue - asp.net

I have a website that sits at http://www.mockcourt.org.uk/mcc/default.aspx this works fine when I'. pointing to it at the address.
However the mcc folder is a secure folder and to make it secure the address is https://secure17.prositehosting.co.uk/mcc/default.aspx but when I point to this it does not work.
The problem is a line of code that I'm using in default.aspx and that is
</asp:DropDownList><asp:AccessDataSource ID="School_DS" runat="server" DataFile="~/App_Data/MockCourt_db.mdb"
I believe that the </asp:DropDownList><asp:AccessDataSource ID="School_DS" runat="server" DataFile="~/App_Data/MockCourt_db.mdb" is saying that the database is at this location but now that I have moved to secure17.prositehosting.co.uk instead of www.mockcourt.org.uk this is no longer valid.
Does anyone know what I should change the code to so it points to http://www.mockcourt.org.uk/App_Data/MockCourt.db

Use an absolute URL to the data file?
</asp:DropDownList><asp:AccessDataSource ID="School_DS" runat="server" DataFile="http://www.mockcourt.org.uk/App_Data/MockCourt.mdb"

Related

Same piece of code works on one page & doesnt work on other Page, asp.net

nesting of image inside a LinkButton shows image on one page & doesn't show image on another page below are two sample code from two different pages in the same root director.It works fine on one page but on the other page is doesn't show any download image rather shows the text download in place of image.
I have done troubleshooting for sometime and replace the code also but it doesnt show download image for any reason on the second page..
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
<asp:LinkButton ID="lnkbtnDownload" runat="server" onclick="lnkbtnDownload_Click" meta:resourcekey="lnkbtnDownloadResource1">
<asp:Image ID="imgDownload" runat="server" ImageUrl="~/images/download.png" meta:resourcekey="imgDownloadResource1" />
</asp:LinkButton>
HTML OUTPUT
HTML for above two code sample render as below
<img alt="Download" src="images/download.png" id="MainContent_imgDownload">
Download
Both Pages are in the same root directory...
The problem probably comes from a discrepancy in your resource files or missing a resource file completely for the second page. Obviously you have one for the first, but possibly not for the other which has different naming.
If you are using meta:resourcekey, there are some things you have to considerate.
Make sure that your local resource files meet the following criteria:
They are in an App_LocalResources folder.
The base name matches the page name.
For example, if you are working with the page named Default.aspx, the
resource files are named Default.aspx.resx (for the default
resources), Default.aspx.es.resx, Default.aspx.es-mx.resx, and so on.
The resources in the file use the naming convention
resourcekey."property". For example, key name Button1."Text".
Source: MSDN

Can't reference controls in code behind. Visual Studio 2012

There are quite a few questions out there regarding this (for me, recurring) issue, but none of them have solved my problem.
Problem:
Whatever control I add in my aspx page, it is not recognised in the codebehind. Compiling doesn't work, because the ID is not recognised.
None of the following worked:
Clean and rebuild solution.
Close and open VS
Delete asp.net temp files
Check project's target framework.
Check assemblies are all there.
Check designer viewn to see if the control is actually there (it is)
Get control's ID with JS function to check it is the intended one (it is)
The problem has started only recently. In fact, I can reference the older controls fine.
The problem is observed both with standard ASP controls and Telerik ones.
Does anyone know of something else I should try? Please help me, I'm in the middle of a project and this is causing unnecessary delays, ta.
Make sure all of your asp.net controls (in the .aspx file) have the:
runat='server'
tag... Without this, you will not be able to reference the controls.
e.g.
<asp:Label runat='server' Text='Test Label' ID='TestLabel' />
Hope this helped...
Rodit
This is how I solved my issue. For a full account of it, please refer to the comments above.
I've noticed that although my project was already of web application type, designer files weren't showing.
I've forced the designer files to be recompiled by clicking on the ''convert to web application' option
I was then able to reference the control ID.
Thanks to the commentators anyway.
I was having a similar issue, due to the fact that I was using the pre-generated Login page. My solution was to change this section from this:
<asp:Login runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
To this:
<asp:Login ID="asplogin" runat="server" ViewStateMode="Disabled" RenderOuterTable="false">
<LayoutTemplate>
basically, I just added an ID to the asp:Login which allowed me to access the objects in the code from behind by prefixing the control name with asplogin
asplogin.youControlNameHere

Presentation Error - SmartTarget Page

When I open an Webpage with SmartTarget configured, I am getting two different errors:
Error 1
First time I get this error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
com/tridion/marketingsolution/profile/Contact
================================================
Some configured classpath roots cannot be found
================================================
ClassPath : C:\tridion\Publicationsites\TestRD\staging\bin\bin
I am not sure how Line 2, comes into the picture, but when I add another bin folder within the already existing bin folder, the error goes. Is something wrong with any of the config file?
Error 2
When I open the page after I apply the workaround for the above error, I receive the following error
Unknown server tag 'smarttarget:Query'.
<smarttarget:Query View="lister" AllowDuplicates="true" Timeout="5000"
Publication="tcm:0-14-1" runat="server" Id="as">
Line 3: <smarttarget:Item runat="server" TemplateUri="tcm:14-1319-32"
ComponentUri="tcm:14-1321"></smarttarget:Item>
Where do I need to add the smarttarget tag? Should it be in the web.config file? Can you please share the syntax. I have tried to accurately implement the ST as mentioned in the live docs. Any area that I need to recheck?
Question 3
I am pasting a screenshot of my Compound Page Template below:
When I publish this page, the HTML markup present in the Main Page Design TBB is not published at all. Only the markup generated by the Add SmartTarget to Promotion TBB exist in the aspx Page.
<smarttarget:Query View="lister" AllowDuplicates="true" Timeout="5000"
Publication="tcm:0-14-1" runat="server" Id="as">
<smarttarget:Item runat="server" TemplateUri="tcm:14-1319-32"
ComponentUri="tcm:14-1321"></smarttarget:Item>
<smarttarget:Promotions MaxItems="2" Region="sidebar" runat="server">
<ItemTemplate>
<smarttarget:PromotionalItems runat="server">
<ItemTemplate>
<tridion:ComponentPresentation runat="server"
PageURI="tcm:14-1119-64"
ComponentURI="<%# Eval("ComponentUri") %>"
TemplateURI="<%# Eval("TemplateUri") %>"/>
</ItemTemplate>
</smarttarget:PromotionalItems>
</ItemTemplate>
<FallbackContent>
<tridion:ComponentPresentation runat='server'
ComponentUri='tcm:14-1322'
TemplateUri='tcm:14-1323-32'/>
</FallbackContent>
</smarttarget:Promotions>
</smarttarget:Query>
Is my implementation correct ?
That's a lot of questions in one entry, but I'll try to answer them here.
Looks like you don't have the right Tridion home directory and it ends up checking 'bin' under the current directory instead. See my blog post on the subject on how this is figured out (and thus how you can solve it): How Tridion Content Delivery loads configuration files (.NET)
This is standard .NET functionality. You can define a prefix in the same page or, as recommended, in the web.config. The exact markup for the web.config is: <add tagPrefix="smarttarget" namespace="Tridion.SmartTarget.Web.UI" assembly="Tridion.SmartTarget" />
Only one "Output" item is used from the package (the last one added). So the way you've split up your Dreamweaver Templates currently would indeed mean that you only get the output from "ST Page Region". I don't know what the intention was with it, so I can't suggest a good way to solve it aside from getting rid of it and putting the tcdl:region directly inside "Main Page Design TBB".
Good luck with it :)

Unable to redirect page in asp.net

I have grid on my asp.net page. grid having 3 columns with hyper links. both links working properly. but one is not redirecting desired page. I tried in different browsers as well . but got different error : as
In Mozilla Firefox :The page isn't redirecting properly
description In Mozilla Firefox :
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
* This problem can sometimes be caused by disabling or refusing to accept
cookies.
In Google chrome : `This webpage has a redirect loop`
description In Google chrome :
The webpage at http://myserver:425/(S(c0kr2xuftxiwhm25cm4vjg45))/mypage.aspx?type=2&userId=8 has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.
since i tried lot of solutions over net , as i tried cleared cookies from browsers, added
<sessionState
cookieless="false" // True also tried
timeout="10">
</sessionState>
in web config file but problem is same there. I checked link is properly redirecting desired page. I mean i checked spelling of my link it is perfect. what else i have to try to resolve it ? where should i am making mistake ?
<ItemTemplate>
Go to my page
</ItemTemplate>
do check anywhere , are you redirecting same page ? I think you need to check each condition throughly , you must be redirecting same page either with same parameter or with different parameters.
Try adding runat="Server" attribute to the link tag, like this:
<ItemTemplate>
<a runat="Server" ID="linkID" href="mypage.aspx?type=2&userId=<%#Eval("userId") %>">Go to my page </a>
</ItemTemplate>
The most obvious place to check is inside mypage.aspx or mypage.aspx.cs for a redirect (see comment by paolo). The problem is not the link from the grid, this is simply a link.
What happens in this case is that you arrive at mypage.aspx, are redirected to mypage.aspx where you are redirected to mypage.aspx, etc.
You can also try this if you have one field in query string. Here in your case you have userid,
<asp:HyperLinkField HeaderText="Your Header"
DataNavigateUrlFields="userId"
DataTextField="Your Data Field to Display"
HeaderStyle-HorizontalAlign="Center"
DataNavigateUrlFormatString="mypage.aspx?type=2&userId={0}"
ItemStyle-Width="35%"
ItemStyle-HorizontalAlign="Left"
/>
In case of multiple
1) DataNavigateUrlFields="userId, employeeId, departmentid"
2) DataNavigateUrlFormatString="mypage.aspx?type=2&userId={0}&employeeId={1}&deptid={2}"
sequence of 1 and 2 must be same.

ASP.NET relative path

I'm confused with ASP.NET relative path, please can someone help?
In a Master Page I gave a link label referencing:
Login
From the ASP.NET official documentation I read:
The following example shows the ~ operator used to specify a root-relative path for an image when using the Image server control In this example, the image file is read from the Images folder that is located directly under the root of the Web application, regardless of where in the Web site the page is located.
<asp:image runat="server" id="Image1"
ImageUrl="~/Images/SampleImage.jpg" />
With the Login markup, when I click the link from a page in the /Account folder, I'm redirected to:
/Account/~/Account/Login.aspx
Why? WHY?h
Because you're using it directly in markup, rather than in a server control. Something as simple as this should fix it:
<a runat="server" href="~/Account/Login.aspx">Login</a>
Basically, the ~ path reference needs to be translated on the server, since it's a reference to the server path of the application's base directory. Plain HTML markup isn't processed on the server, it's just delivered as-is to the client. Only server-processed code will translate the ~ path to what it resolves to.
use this command
<a href="<%=Page.ResolveUrl("~/product.aspx")%>" >Link To Products</a>
You can use ~ when refering to URLs inside ASP.NET Server Controls.
You are using it in a <a> tag which is just plain html that doeesn't know anything about ~ . use '"/Images/SampleImage.jpg"' instead

Resources