Asp.net + Google Charts - Attached html file won't open correctly - asp.net

I have an Asp.Net page containing one grid and an image. The image is a google charts chart and its urls is around 1600 characters. I out together an .htm file containing the grid and the image. For the grid I use RenderControl to get its html code, and for the image, I just add an img html tag and assing the url to its src. I then send this .htm file as an email attachment.
My problem is that when you try to open the attached file, you see everything ok except the image (it doesn't show anything and when you look at the source code for the page, the img tag doesn't show any src whatsoever - it just shows < img > (without the spaces). If you open the file after you save it to disk, then it all works fine and you see the actual img src. Why???
Here's my html header:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>
And here's the image:
<img src="http://chart.apis.google.com/chart?chd=t:0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,420.95,0.00,2725.25,0.00,0.00,0.00,0.00,5036.96,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,47.82|0.0000,7.97,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.98,1.99,2.24,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.99,1.99|0.5100,34.04,0.00,0.00,0.00,0.00,0.00,0.00,1.00,0.00,0.00,0.00,0.00,0.00,0.00,36.77,18.01,18.26,0.00,0.00,0.00,0.00,0.00,8.99,0.00,20.06,14.01|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.00|3.0000,0.00,0.00,0.00,0.00,0.00,0.00,0.00,46.98,0.00,257.91,113.25,0.00,0.00,0.00,1.00,24.99,29.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,60.00,123.92|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,45.00,0.00,0.00,0.00,0.00,0.00,0.00,20.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,84.00|0,55.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,65.99&chdl=Type 1|Type 2|Type 3|Type 4|Type 5|Type 6|Type 7&chco=000000,CD7F32,A62A2A,0000FF,00FF00,FF6EC7,A8A8A8&chds=0,5037&chxl=0:|6/22|6/23|6/24|6/25|6/26|6/27|6/28|6/29|6/30|7/1|7/2|7/3|7/4|7/5|7/6|7/7|7/8|7/9|7/10|7/11|7/12|7/13|7/14|7/15|7/16|7/17|7/18|1:|0|503|1006|1509|2012|2515|3018|3521|4024|4527|5037|2:|Days|3:|Amount ($)&chls=3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0&chm=o,990066,0,-1,6.0|o,990066,1,-1,6.0|o,990066,2,-1,6.0|o,990066,3,-1,6.0|o,990066,4,-1,6.0|o,990066,5,-1,6.0|o,990066,6,-1,6.0&chg=3.85,0&cht=lc&chs=900x300&chxt=x,y,r,t"/>
If the problem is the size of the URL, what are my choices, short of building a pdf file and attaching it? It seems that an html file is all I need and I would like to keep it simple.

You could definitely be seeing a long URL problem. That happened to me when I was using Google Charts API (albeit in Rails rather than ASP.NET). I never could find the exact URL size that started to cause trouble, but some people reported troubles starting at 1024.
Google provides a couple of different encoding types you can use on the input data to shrink it, but using anything other than text encoding (what you are doing) will disable your ability to scale the data, if you care about that.
If you cannot scale the data, you may get some ugly graphs if the data stays at the maximum for long stretches or if you want to overlay two graphs with different scales.
See data formats from Google Chart API Docs

If the GET is too long you could use a POST instead you'll have a 16k limit which is more than enough. I've used the code below to generate your chart and it worked. So yes I guess you could use the post and attach that to the email. Perhaps the problem with using GET is an issue with the email client configured to not opening image files, have you tested it in other clients?
<form action='http://chart.apis.google.com/chart' method='POST' id='post_form'>
<input type="hidden" name="cht" value="lc" />
<input type="hidden" name="chtt" value="Demo chart" />
<input type="hidden" name="chg" value="3.85,0" />
<input type='hidden' name='chs' value='900x300' />
<input type="hidden" name="chxt" value="x,y,r,t" />
<input type="hidden" name="chds" value="0,5037" />
<input type="hidden" name="chxl" value="0:|6/22|6/23|6/24|6/25|6/26|6/27|6/28|6/29|6/30|7/1|7/2|7/3|7/4|7/5|7/6|7/7|7/8|7/9|7/10|7/11|7/12|7/13|7/14|7/15|7/16|7/17|7/18|1:|0|503|1006|1509|2012|2515|3018|3521|4024|4527|5037|2:|Days|3:|Amount ($)" />
<input type="hidden" name="chls" value="3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0|3,1,0" />
<input type="hidden" name="chm" value="o,990066,0,-1,6.0|o,990066,1,-1,6.0|o,990066,2,-1,6.0|o,990066,3,-1,6.0|o,990066,4,-1,6.0|o,990066,5,-1,6.0|o,990066,6,-1,6.0" />
<input type="hidden" name="chco" value="000000,CD7F32,A62A2A,0000FF,00FF00,FF6EC7,A8A8A8" />
<input type="hidden" name="chdl" value="Type 1|Type 2|Type 3|Type 4|Type 5|Type 6|Type 7" />
<input type='hidden' name='chd' value='t:0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,420.95,0.00,2725.25,0.00,0.00,0.00,0.00,5036.96,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,47.82|0.0000,7.97,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.98,1.99,2.24,0.00,0.00,0.00,0.00,0.00,0.00,0.00,1.99,1.99|0.5100,34.04,0.00,0.00,0.00,0.00,0.00,0.00,1.00,0.00,0.00,0.00,0.00,0.00,0.00,36.77,18.01,18.26,0.00,0.00,0.00,0.00,0.00,8.99,0.00,20.06,14.01|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,2.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,4.00|3.0000,0.00,0.00,0.00,0.00,0.00,0.00,0.00,46.98,0.00,257.91,113.25,0.00,0.00,0.00,1.00,24.99,29.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,60.00,123.92|0,0.00,0.00,0.00,0.00,0.00,0.00,0.00,45.00,0.00,0.00,0.00,0.00,0.00,0.00,20.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,84.00|0,55.99,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,65.99'/>
<input type="submit" />

Related

Request.Form - Getting null responses [duplicate]

I have following form,
<form action="contact_us.asp" method="post" enctype="multipart/form-data" name="form1" id="form1">
<input name="firstname" type="text" id="firstname" size="30" />
<input name="lastname" type="text" id="lastname" size="30" />
<input type="submit" name="submit" id="submit" value="Submit" />
</form>
But when I am trying to get value of these post variables in my ASP file contact_us.asp then it returns blank. Code is below:
<%#LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<%
Dim FirstName, LastName, Email, Message
FirstName = request.form("firstname")
LastName = request.form("lastname")
response.write(FirstName & "OK")
%>
Its returning only "OK" to me. nothing in Message variable?
Please help me and tell me what's wrong here?
Classic ASP doesn't provide built-in support for working with `multipart/form-data. This is a surprisingly basic deficiency even for a language of ASP's venerable age, but what're you gonna do about it, move to ASP.NET? (Yes? oh. well never mind then.)
If you aren't doing file uploads, it's easiest just to stick with the default enctype (which is application/x-www-form-urlencoded). The only advantage of multipart/form-data is that you can put file uploads in it. (Theoretically, it would also have the advantage that you can specify character encodings definitively. But no browser actually does that.)
If you do need to handle multipart/form-data in Classic ASP you will need to parse the incoming request body yourself, splitting it into fields and values. Or rather, more typically, use an existing library to do it*.
That library will usually provide separate interfaces for reading the uploaded files and the other form values. This completely replaces use of the Classic ASP Request.Form interface. Exactly where you can find it depends on the library you choose. This does mean that if you want to have a form that can respond to either enctype equally you have to check the type and use one of the two different interfaces.
*: There are loads. for example. I'm not endorsing either of these as such... neither of them actually parse multiparts properly as per the standard and both seem a bit lax about filename security (never store a file under the user-submitted filename! security disaster!). But that seems to be par for the course for ASP upload scripts. At least, unlike many, they're not asking money for them.
I found by removing enctype completely (which defaults to application/x-www-form-urlencoded) from the form tag that Request.Form("SomeInputTagId") worked fine with method="post". I also didn't need to install any third party readers. Hope this helps.
Don't use enctype="multipart/form-data"
Remove that from the code and see if it works. The form-data enctype is used for uploading data, for example image files. You need to access the form elements slightly differently if you use that enctype.
If you are uploading data, then the ASP object you are using (for example ASP Upload) will have functions to access form fields. Request.form("") wont work.
Accessing the form values would be along the lines of:
Set yourUploadComponent = CreateObject("Your.UploadComponentClassString")
sFormValue = yourUploadComponent.Form.Item("txtName").Value
You will need to read the objects documentation.

Request.Form is nothing when the object is disabled

I Google and search every article here and in the google but i cannot find anything regarding this issue. Any idea why the request.form["name here"] is nothing when the html control is disabled something like
<input type="radio" name="name here" disabled />
removing disabled would return the values. I tested this only on IE 10 not sure on other browsers.
I am looking into changing the css of the radio button but that is a different story.
Thank you.
Disabled form fields are not part of the posted data. If you disable the html control the data will not be posted.
If you want to show the data and have it posted, but not possible to edit you can set the control to readonly instead.
<input type="radio" name="name here" readonly="readonly" />

Jquery sliders do not work in aspx page but works fine in HTML

Scenario:
Within an asp.net site, we have 3 jquery sliders on ASPX page.
The three sliders (can be seen in the below jsfiddle link) are
a) Price
b) Variant
c) Related items (it is within the tab)
The JSfiddle link is below.
http://jsfiddle.net/DfKwy/5/
The 3rd slider (related-items sliders) is creating problem such as the previous & next arrow buttons do not slide and also when this slider is present, the other sliders do not slide (user doesn't get to see previous / next buttons).
I just took html/script/css from the aspx page and put them in jsfiddle & everything seems to be working. However on the live asp.net it doesn't work. I have made the asp.net as public facing and I can share the url also.
The aspx page uses updatePanel, ajax. Even in my jsfiddle example I have commented some script blocks.
Please help in debugging this further.
PS: For some reason, I can't submit this question without posting code. Please check the above jsfiddle link for complete code. The below code is just couple of lines only and is not complete.
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
</div>
Maybe there are other scripts/line of codes affecting your desired outcome? Maybe your'e referencing conflicting jquery versions such?
Please see link.
conflict between jquery-1.2.6.min.js and jquery-1.4.2

copy and pasting into web input box causes strange behavior?

i have a plain html form on a windows box running windows server 2003. I have come upon something very strange. I input items into an input box and click submit. It safely post to the next page. However if i copy and paste into the box its hit or miss. More miss then hit. WHat i mean is that the input box eventhough has values in it does not seem to post the values to the next aspx page. This is racking my brain.
<form name="sending" method="POST" action="https://xx/Retrieveimg.aspx" target="_self">
<font size="2">invoice :</font><br>
<input name="img" size="50" runat="server">
<input type="submit" value="Send" name="Send">
</form>
has anyone ever seen this behavior before?
I dont see you have an ID for the input which has a runat="server" attribute. Add an ID and try again.

Any work around for this issue -- when going back and forth between pages in Firefox the focus is lost at different points

I have a page that is rendered through xulrunner service. There is a form and a button under the form.
For accessibility requirement, I forced the focus on the text field within the form when the user navigates to this page. However, sometimes JAWS always reads the Post Comment button label. Sometimes, JAWS reads the aria-label “Enter Comments”.
Here is the code:
<body onLoad="document.addcommentform.comment.focus()">
<input type="textarea" aria-label="Enter Comments" title="{$enterComment}" name="comment" />
<input class="Button" type="submit" value="{$postComment}" />
I also tried to put a visible label on the UI like this. I did more testing and found out the behavior is pretty the same.
<label for="addcommentform">Please enter comment
<form method="get" action="{$self}" name="addcommentform">
<textarea title="{$enterComment}" name="comment" class="commentarea" </textarea>
<input class="Button" type="submit" value="{$postComment}" />
</form>
</label>
I think it is related to this known bug https://bugzilla.mozilla.org/show_bug.cgi?id=133771
But does anybody known any workaround to this issue?
I'm a Jaws user and don't know of a way around this. Since Jaws tends to create it's own model of pages in a virtual buffer things can behave slightly differently then you would expect. To confirm or disprove weather it's a Jaws specific bug I would suggest trying out NVDA an open source and quite good Windows screen reader.

Resources