use html to get image and create link from database - asp.net

I have a column in my database that stores images that are links, when i populate them in a gridview on my asp.net page I want it to display the image as a link but when i did it i just get the text below.
<img src="http://www.url.com/url/url/url/url.jpg">
My goal is to have a list of the images and when a user clicks the image they will go to another page. This is a start of my page, and i was attempting to use a gridview but now I am not sure what to do

Don't save markup
Instead just save a URL. In your case two of them since one points to *.html and the other to *.jpg. Or just without extensions if they're always the same except for the extensions. This way you can easily change your markup later and still use the same data from the DB.
But apart from this fact of not saving non-data in DB you could at least provide some relevant code you're using. We'd much easier tell you where you're doing it wrong.
Using GridView
The problem you're having are column templates. Check this link out and see how you can customize the display of a particular column in a GridView. Essentially you will have to provide your own template and do whatever you please with your DB data.

Related

Wordpress - Display Content Conditionally

I am fairly new to Wordpress. I am writing a real estate site, and I want to have a Service Area page that displays the Counties that we serve in various states. So what I want to happen is to have a dropdown list where a user can select a state, and based on the state that they select, a text area will display that counties that we service in that state.
So basically, I want to store text content in the form of counties that will be displayed based on the conditions of a dropdown list.
I have no idea where to start. Is there a plugin that works for this kind of situation such as a form plugin that can store content, or am I going to have to write custom PHP/Javascript to make something like this happen. I am asking because this seems like a common scenario on websites, I just don't know where to look.
Thanks for any suggestions that you may have!!
So what I ended up doing was creating a select box in html that when a change happened on the list, a javascript function was called that changed the visibility of a text area and also set the value of its content to display all the counties that I needed. Ended up being much more simple than I expected. No PHP functions and short code necessary.

Replace image field content in Drupal

I have a content type with image field and need to replace it with another image already uploaded on server. Best would be to do it with AJAX call to avoid page reload.
Is it just a matter of replacing "fid" in node's field value?
I've been messing with the ajax framework lately myself. There are probably better approaches, but the difficulty is in placing multiple ajax events on a single form element and file fields already have one on them.
One option could be to implement hook_ajax_render_alter, and add to/modify/replace what file_ajax_upload() provided in the $commands array as needed..

WordPress - add Database driven tables

I'm just trying to move one of my old php sites to wordpress. As part of the site I have 'top tables' e.g. top 10 cars, listing their features etc. At the moment that all comes from a database and the HTML is generated from the data.
So if a car soon gets a hybrid engine I just check that in the database and my web site table updates to reflect that.
This all works fine. I just don't know where to start when trying to implement something like this in wordpress. I want to keep the WP header, footer, nav... and put my table in to the content area.
Someone recommended simply copying the current generated HTML in to a new post and editing the HTML when anything changes, this sounds like a quick solution but there must be a better way of doing this.
Ideally I would want to keep my current data input pages (and separate database) for all of this 'table data' and present the out put as a post.
If anyone can point me in the right direction (key words I should search for, a guide) that would be great.
Depending on your usecase, you'll usually want to use a static page template:
http://codex.wordpress.org/Page_Templates
Or shortcodes:
http://codex.wordpress.org/Shortcode_API

Django: Hiding necessary forms on template page

I have a Django application which takes the lat/lon from a user's coordinates via HTML5 geolocation and places these into form fields via jQuery. Markers are then placed on a map using these coordinates. This works very well.
The problem: I want to hide these forms so they're invisible to the user, but these still need to be "on the page" so they can receive the information. So excluding these via the Django forms file won't be acceptable.
I tried one method which hid the form field but left the form label. I'd like to hide the entire row from the user and remove the space where the form field exists while it still remains in the background to receive the info.
Is this possible? Not sure if it requires a CSS trick or a something built-in to Django.
Any help or insight appreciated.
Give your forms an ID and in CSS set display: none for these IDs. Alternatively, use a common class instead of separate IDs.

How to avoid querystring being accessible in ASP.Net dynamically generated chart?

To create dynamic charts and graphs in ASP.Net, I have placed the (GDI+) code for each chart in separate page files – so the output from running a chart page by itself if to just display the chart onscreen.
The chart page contains the code to get the relevant data from SQL Server, as well as the chart generation code. The generated chart object is then saved to Response.OutputStream.
A content page where I want to display the chart provides various parameters to determine what data will be used to generate the chart (such as userID, project ID, selection from dropdown lists etc.).
To display the chart as part of a content page, I then place an image object in the page, collect the various chart parameters, and in code behind set the URL of the image object to be the chart page, plus all the chart parameters added to the query string.
This works fine, except for one thing: when I right click on the chart image as it appears in the content page in the browser, I get an option to “open image”, which displays a page with the chart all by itself (perhaps not surprising as it is generated with a chart page). However, the problem is that in this chart page, the full URL with the querystring is visible, which means that a user could change the values in the query string, and thereby generate a new chart. This is a big problem, as it might enable a user to generate a chart for data they should not have access to.
Is there a way to avoid this problem whilst still using this “chart page” approach to generating and displaying dynamic charts? Alternatively, should I rather save the dynamically generated images as files, either on disk or as SQL Server Filestream objects for example, and then reference these in the page?
By the way, I am aware of the various ASP.Net chart controls that are available. However, the charts I need to generate are highly customised to a very specialised application, so those controls will unfortunately not work in this instance.
I have the same concern for one of my previous projects. One cheap but not 100% fool-proof solution is to insert a http-referer check before you process the image. Images loaded from within you page will have the referrer URL of your domain, those entered directly via the browser won't have.
Of course it's very easy to hack by faking referrer url, still it is some form of deterrent. Will be glad if others can offer their solutions.
Another way is to add some sort of checksum params into your querystring. Only you know how to 'decrypt' and only generate image when the checksum is 'correct'.
First of all, I assume that your users are authenticated (logged in) to your website, so you know who they are and what data/charts they are supposed to have access to?
You need to check the incoming parameters in your image-generating code to see if the current user has access to the data he asks for. Typically you would query your user/privilege tables for this (or call the Membership API or whatever).
Trying to hide the URL (for example by doing a POST instead of a GET to the image-generating page) is just "security by obscurity", which is not a good idea.
By the way, your problem is called "URL tampering", a Google search for this should get you in the right direction.

Resources