For what is used ' <%#data: ... ' in embedded code blocks? - html

I am trying to insert images in a GridView Table, the image is saved as base64 in a SQL DataBase, I found in a youtube video, that you can retrieve and make the data binding with an embedded code block
<%# ... %>
They are using also this:
<DataItemTemplate>
<asp:Image ID="Foto" runat="server" ImageUrl='<%#"data:Image/png;base64," + "ImageData" %>'></asp:Image>
</DataItemTemplate>
For what is the data:Image/png, is it just format? and how is it called to search it online?
Thanks in advance.
Video consulted: https://www.youtube.com/watch?v=sFkeJb7E_rk&t=427s (min 4:15)

data:Image/png;base64,... is called data URI scheme or RFC 2397.
There're two parts of the solution you are using:
The part using <%# ... %> is used by ASP.NET to embed C# or VB code inside your ASPX page. In your example you are promoting a string to your HTML page with the data URI printed.
The data:Image/png;Base64,... is actually used to embed a binary image inside your page. You can look at this reference more details and examples (if you do not like the RFC standard document - which is sometimes harder to read).

Related

How to pass a string into an iframe python

Basically I have a list of urls, I want to automatically pass into an iframe src, for it to process and view it. How to do that?
example :
urls_arr=['xyz.com','ybk.com']
for i in urls_arr:
st.markdown(<iframe src=i></iframe>)
basically i am running an app in streamlit and i am using it to embed power bi reports. the urls are actually the report embed urls.
example :
urls_arr=['xyz.com','ybk.com']
for i in urls_arr:
st.markdown(<iframe src=i></iframe>)
reports not opening
You should wrap the markdown in an f-string and add unsafe_allow_html=True. something like:
urls_arr=['xyz.com','ybk.com']
for i in urls_arr:
st.markdown(f"<iframe src='{i}'></iframe>", unsafe_allow_html=True)

Error with generate and downloading MVC view to PDF function (Itext - System IO.IO this document has no pages)

I'm new to ASP.NET MVC and not that good with coding. I'm trying to download my returned list from view as a PDF document
The exact error I get is:
System.IO.IOException
HResult=0x80131620
The document has no pages.
Source=itextsharp
StackTrace:
at iTextSharp.text.pdf.PdfPages.WritePageTree()
at iTextSharp.text.pdf.PdfWriter.Close()
at iTextSharp.text.pdf.PdfDocument.Close()
at iTextSharp.text.Document.Close()
My controller with function
My view html
Your problem is in your jquery and your html, you are not passing any values into your div, your table is also not in your div. Thus jquery is pulling nothing, that means that your stream is getting no bytes.

output a variable in rails containing html code Ruby on Rails

I have a little problem with an output in ruby and rails.
I am still a beginner at rails, so it can be that the solution is pretty easy and i just can't see it.
I am trying to parse a website and put out some of the sourcecode on my own website.
Problem: it always puts out the whole source code as a text and is not interpreting the html code. how can i change that?
code:
page = Nokogiri::HTML(open("https://www.google.ch/search?client=ubuntu&channel=fs&q=google&ie=utf-8&oe=utf-8&redir_esc=&ei=WMpyUfSWEuz07AaTioCwDw"))
source = page.css('div#_css0')
<%= page %>
result:
http://postimg.org/image/dsaib9lx3/
I want to it to look like:
http://postimg.org/image/z9qlhoef5/
Thanks for any suggestions!
You should use raw in erb. It is actually equivalent to calling html_safe on it, but, just like h, is declared on a helper, so it can only be used on controllers and views.
page = Nokogiri::HTML(open("https://www.google.ch"))
<%= raw page %>
or
<%= raw Nokogiri::HTML(open("http://www.google.com")) %>
In Rails views every string content gets escaped, unless you use html_safe (docs)

Passing a value through hyperlink in JSP page

I have a very simple JSP page first.jsp that gives reference to so many other JSP pages through hyperlink.
I am trying to pass a value through the hyperlink in first.jsp and retrieve it in second.jsp using request.getparameter().
I used:
Second JSP
and in the second.jsp page I used:
alert( "value = " + <%= request.getParameter("value") %>);
but when I try to run the code and click on Second JSP I get a 404 page not found error for:second.jsp?value=1
It looks like your URL to second JSP might not be good. "second.jsp" is not visible to your web app server the way you specified.
To fix this:
If your jsps are resolved through a web app try:
Second JSP
if you have jsp or similar directory that is visible outside of web app context do something like:
Second JSP
Try getQueryString() method to access the value that you passed through the URL.
Then use string methods to extract the value form the URL.
For example, you pass the parameter as you mentioned
Use getQueryString() method in second.jsp, it will return the string value = 1 as the result.
Html:
<a href="birth1.jsp?key=14APR010315381">
<center>
<font size="2" color="black">MIKE LOBO</font></center>
</a>
Jsp:
request.getParameter("key");
I m using in my project and its working fine

Using SSI in HTMLs imported using c:import in jsps

I have a bunch of htmls in the webserver context (outside the application context) in the htdocs area. These htmls use SSI to call other htmls.
Here's the problem:
When I use c:import to call the main html into the jsp, the secondary htmls inside the main html don't render / are not processed.
Is there a way to get the main html to "compile" and then return to the jsp?
JSP codes:
<c:import url="<%=/folder/Header.html%>"
HTML server side logic that needs to be processed:
<!--#include virtual="/abc/xyz.html" -->
<!--#if expr='"$Category" = "someCategory"' -->
<!--#echo var="pageTitle" -->
The prototypes were given as all htmls, so everything was in the web context and all files worked fine. The issue is moving the top layer to JSP and keeping the rest of the layers as HTML. (Its a requirement)
Any solutions /thoughts/ ideas would be welcome! Thanks for your asssistance!
Wave
EDIT: Ok, I'm getting the Header.html in an iFrame because that will initiate a new HTTP request (and thus have access to the SSI logic).
<iframe id="testSSI" src ="http://somesite.com/subfolder/testssi_1.html?pageTitle=Applications" frameborder="0" width="800px" height="300"></iframe>
The parameters are sent in the URL and I've managed to extract the control parameters using js.
My query has reduced to this:
How can I access this js value "Applications" in the SSI logic? Is it possible to set is as an environment variable? That could be pulled by the SSI logic.. I realise that the Js will run after the SSI is done, but hoping someone here would be able to help.
Thanks!
Thanks, got it done.
I accessed the parameter in SSI by using the QUERY_STRING environment variable.
Example of html call:
http://somesite.com/subfolder/testssi_1.html?Applications
Example of how i retrieved the value:
<!--#set var="pageTitle" value="$QUERY_STRING" -->
<!--#if expr=" ${pageTitle} = Program " -->
do something
<!--#else -->
do something else
<!--#endif -->
The objective here:
We use a JAVA framework. But Marketing wanted content to be editable by them in a separate process.This way, they can change the content frequently with out the intervention on the jsp / java team. (Eg. change header look and feel, add new links, etc)
Hope this helps someone out later. :)
Wave
Edit: In the example above -> "Applications" will take the logic to the else section..
In addition, to send name value pairs:
http://somesite.com/subfolder/testssi_1.html?name=Applications&app=Demo
you can reference them as:
<!--#if expr=" ${QUERY_STRING} = /name=Applications/ " -->
AND
<!--#if expr=" ${QUERY_STRING} = /app=Demo/ " -->