I'm fairly new to Kentico and I'm trying to create a prepeater for print form .
i need to print form with background image .
pls help me .
my code is :
http://prs.bimehasia.ir/%D9%85%D8%AF%DB%8C%D8%B1%DB%8C%D8%AA-%D9%87%D8%A7/%D8%B7%D8%B1%D8%AD-%D9%88-%D8%AA%D9%88%D8%B3%D8%B9%D9%87/%DA%A9%D8%A7%D8%B1%D8%AA%D8%A7%D8%A8%D9%84/%DA%AF%D9%88%D8%A7%D9%87%DB%8C%D9%86%D8%A7%D9%85%D9%87-%D8%AF%D9%88%D8%B1%D9%87-%D8%A7%D9%85%D9%88%D8%B2%D8%B4%DB%8C/04.jpg'); background-size: 100% 100%;">
گواهینامه دوره آموزشی
شماره: <%# IfEmpty(Eval("CertificateID"), "", Eval("CertificateID"))%>
<%# GetCatName1(Eval("CertType"))%>
تاریخ: <%# CustomFunctions.GetDate(ValidationHelper.GetDateTime(Eval("CertDate"), DateTime.Now),"yyyy/MM/dd") %>
گواهی میشود :
سرکار خانم / جناب آقای :
<%# IfEmpty(Eval("prsFullName"), " " , Eval("prsFullName"))%>
با شماره پرسنلی
<%# IfEmpty(Eval("prscode"), " " , " " + Eval("prscode"))%>
دوره آموزشی
<%# IfEmpty(Eval("CourseName"), " " , " " + Eval("CourseName"))%>
را در تاریخ
<%# CustomFunctions.GetDate(ValidationHelper.GetDateTime(Eval("EndDate"), DateTime.Now),"yyyy/MM/dd") %>
و به مدت
<%# IfEmpty(Eval("Courselength"), " " , Eval("Courselength"))%>
ساعت در
<%# IfEmpty(Eval("TrainingName"), " " , Eval("TrainingName"))%>
استان
<%# IfEmpty(Eval("Provincename"), " " , Eval("Provincename"))%>
شعبه
---
با موفقیت به پایان رسانیده است.
<%# IfEmpty(Eval("DevelopManagerName"), " " , Eval("DevelopManagerName"))%>
<%# IfEmpty(Eval("AssistanceDevelopName"), " " , Eval("AssistanceDevelopName"))%>
معاون توسعه و برنامه ریزی
مدیر طرح و توسعه
<!---اسکریپت ها --->
<script runat="server">
string GetCatName1(object Name)
{
var input = ValidationHelper.GetInteger(Name, 0);
switch(input)
{
case(1): return "(کارکنان)";
default: return "(شبکه فروش و نمایندگان)";
}
}
</script>
Printing (or not printing) of background images are in control of your browser and its settings. Check this thread for more details.
Related
I have a custom taglib and i'm passing it some attributes. I want it to output a input field with the attributes I pass in.
def selectField = { attrs ->
System.out.println( attrs.class );
out << "<input id=" + attrs.id + " class=" + attrs.class + " name=" + attrs.name + " />"
}
When I print out class I get this
"span2 myinput"
Call element in gsp file
<mynamespace:selectField class="span8 myinput" name="pay" id="myid" data-user="${blaaaa}"/>
When I check the input element that was rendered by the selectField method I get this
<input id="myid" class="span8" myinput="" name="pay">
Can't seem to get it to accept class with multiple names. It seems to accept one string only for the class and then prints the other by itself as another attributes
It should be
<input id="myid" class="span8 myinput" name="pay">
you are still using String concatenation and no quotes in the output.
This is how the tag should look like:
def selectField = { attrs ->
out << '<input id="' << attrs.id << '" class="' << attrs.class << '" name="' << attrs.name << '" />'
}
you might want to take a look at org.codehaus.groovy.grails.plugins.web.taglib.ApplicationTagLib source code to see how the tags should be implemented
I have the following HTML in a variable named html_data where I wish to replace <img> tags with <a> tags and the src parameters of the "img" tags becomes href of the "a" tags.
Existing HTML:
<!DOCTYPE html>
<html>
<head>
<title>Learning Nokogiri</title>
</head>
<body marginwidth="6">
<div valign="top">
<div class="some_class">
<div class="test">
<img src="apple.png" alt="Apple" height="42" width="42">
<div style="white-space: pre-wrap;"></div>
</div>
</div>
</div>
</body>
</html>
This is my solution A:
nokogiri_html = Nokogiri::HTML(html_data)
nokogiri_html("img").each { |tag|
a_tag = Nokogiri::XML::Node.new("a", nokogiri_html)
a_tag["href"] = tag["src"]
tag.add_next_sibling(a_tag)
tag.remove()
}
puts 'nokogiri_html is', nokogiri_html
This is my solution B:
nokogiri_html = Nokogiri::HTML(html_data)
nokogiri_html("img").each { |tag|
tag.name= "a";
tag.set_attribute("href" , tag["src"])
}
puts 'nokogiri_html is', nokogiri_html
While solution A works fine, I am looking if there is a quicker/direct way to replace the tags using Nokogiri. With solution B, my "img" tag does get replaced with the "a" tag, but the properties of the "img" tag still remains inside the "a" tag. Below is the result of Solution B:
<!DOCTYPE html>
<html>
<body>
<p>["\n", "\n", " </p>
\n", "
<title>Learning Nokogiri</title>
\n", " \n", " \n", "
<div valign='\"top\"'>
\n", "
<div class='\"some_class\"'>
\n", "
<div class='\"test\"'>
\n", " <a src="%5C%22apple.png%5C%22" alt='\"Apple\"' height='\"42\"' width='\"42\"' href="%5C%22apple.png%5C%22"></a>\n", "
<div style='\"white-space:' pre-wrap></div>
\n", "
</div>
\n", "
</div>
\n", "
</div>
\n", " \n", ""]
</body>
</html>
Is there a way to replace the tags faster in HTML using Nokogiri? Also how can remove the "\n"s am getting in the result?
First, please strip your sample data (HTML) to the barest amount necessary to demonstrate the problem.
Here's the basics of doing what you want:
require 'nokogiri'
doc = Nokogiri::HTML(<<EOT)
<!DOCTYPE html>
<html>
<body>
<img src="apple.png" alt="Apple" height="42" width="42">
</body>
</html>
EOT
doc.search('img').each do |img|
src, alt = %w[src alt].map{ |p| img[p] }
img.replace("<a href='#{ src }'>#{ alt }</a>")
end
doc.to_html
# => "<!DOCTYPE html>\n<html>\n <body>\n Apple\n </body>\n</html>\n"
puts doc.to_html
# >> <!DOCTYPE html>
# >> <html>
# >> <body>
# >> Apple
# >> </body>
# >> </html>
Doing it this way allows Nokogiri to replace nodes cleanly.
It's not necessary to do all this rigamarole:
a_tag = Nokogiri::XML::Node.new("a", nokogiri_html)
a_tag["href"] = tag["src"]
tag.add_next_sibling(a_tag)
tag.remove()
Instead, create a string that is the tag you want to use and let Nokogiri convert the string to a node and replace the old node:
src, alt = %w[src alt].map{ |p| img[p] }
img.replace("<a href='#{ src }'>#{ alt }</a>")
It's not necessary to strip extraneous whitespace between nodes. It can affect the look of the HTML but browsers will gobble that extra whitespace and not display it.
Nokogiri can be told to not output the inter-node whitespace, resulting in a compressed/fugly output, but how to do that is a separate question.
I am trying to show products fetched from database by creating a user control ProductBox and inside it setting the parameters to be shown from the Model. But the following block of code shows the unhandled exception : strUrl doesn't exist in the current context.
I am totally new to MVC. Can you help me spot where the parenthesis is missing?
Here is my code from ProductBox user control.
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TSRApp.UI.Models.ProductBox>" %>
<%# Import Namespace="TSRApp.UI.Helpers" %>
<%# Import Namespace="TSRApp.Contracts.Common.OperationalContracts" %>
<% string strStartTag = "<div class=\"fl book-shaddow\">";
string strEndTag = "</div>";
if (Model.IsFeatured)
{
strStartTag = "<li " + Model.LiID + " >";
strStartTag = strStartTag + "<div class=\"book-shaddow\">";
strEndTag = "</div></li>";
}
if (Model.ProductName.Length > 40)
{
Model.ProductName = Model.ProductName.Substring(0, 37) + " ...";
}
if (string.IsNullOrEmpty(Model.ProductZoomImage))
{
if (!string.IsNullOrEmpty(Model.ProductSmallImage))
{
string strZoomImage = Model.ProductSmallImage.Substring(Model.ProductSmallImage.IndexOf("src=")).Replace("src=\"", "");
strZoomImage = strZoomImage.Substring(0, strZoomImage.IndexOf("\""));
Model.ProductZoomImage = strZoomImage;
}
else
{
Model.ProductZoomImage = Model.ProductSmallImage.Replace("~", "");
}
}
string strURL = string.Empty;
strURL = "/Product/Information/" + Model.ProductCode;
%>
<%= strStartTag %>
<% if(UiHelper.GetDeviceID()!=4)
{
%>
<%
}
%>
<% if (!string.IsNullOrEmpty(Model.ProductSmallImage))
{
%>
<%= Model.ProductSmallImage%>
<%
}
%>
<img src="<%=Model.ProductSmallImage %>" alt="<%= Model.ProductName %>"
style="height: 200px; width: 170px" />
<%= strEndTag %>
Kindly help me fix this issue.
Thanks.
C# is case-sensitive. Change <%=strUrl %> to <%=strURL %> and you should be good to go.
I have 2 views, one called PostToPalPal as below and DomainConfirmationView. On the DomainConfirmationView i have a button that is linking to PostToPayPal which then redirects to paypal via a post event. The problem i have is when i click on this button it does not do anything. I have got this working on another page however i only had #model dynamic at the top of the page and the rest was HTML. Does anyone have idea's where i am going wrong? Apologies if this is something really dumb, this is a my first go at MVC.
Thanks
#model application.Models.PayPal
#{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
<script src="#Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script>
</head>
<body>
<form id="frm" action=#ViewBag.actionURL>
#Html.HiddenFor(model => model.cmd)
#Html.HiddenFor(model => model.business)
#Html.HiddenFor(model => model.no_shipping)
#Html.HiddenFor(model => model.#return)
#Html.HiddenFor(model => model.cancel_return)
#Html.HiddenFor(model => model.notify_url)
#Html.HiddenFor(model => model.currency_code)
#Html.HiddenFor(model => model.item_name)
#Html.HiddenFor(model => model.amount)
</form>
<p style="text-align: center">
<h4>
<img src="../../Images/New-LogoPNG.png" />
<br />
You are now being redirected to Paypal...</h4>
</p>
</body>
</html>
<script type="text/javascript" language="javascript">
$(this.document).ready(function () {
var frm = $("form");
frm.submit();
});
</script>
DomainConfirmationView
#model Application.Models.DomainCustomerDetails
#using (Html.BeginForm("PostToPayPal", "Home"))
{
<input type ="hidden" name="item" value= ".com"/>
<input type = "hidden" name="amount" value="10" />
}
#{
ViewBag.Title = "Domain order placed";
}
#{
String Input = "Hi" +".<BR /><BR />"
+ "You have a new domain order that has been placed."
+ "<BR /><BR />"
+ "Domain Details"
+ "<BR /><BR />"
+ "Domain name:" + Model.DomainName
+ "<BR /><BR />"
+ "Domain duration " + Model.DomainDuration
+ "<BR /><BR />"
+ "Domain order type" + Model.OrderType
+ "<BR /><BR />"
+ "<BR /><BR />"
+ Model.FirstName
+ "<BR /><BR />"
+ Model.LastName
+ "<BR /><BR />"
+ Model.BusinessName
+ "<BR /><BR />"
+ Model.Address
+ "<BR /><BR />"
+ Model.Address2
+ "<BR /><BR />"
+ Model.PostalCode
+ "<BR /><BR />"
+ Model.EmailAddress
+ "<BR /><BR />"
+ Model.ContactNumber
+ "<BR /><BR />"
+ "<BR /><BR />"
+ "Kind regards"
+ "<BR /><BR />"
+ "xxx"
+ "<BR /><BR />"
+ "Email: support#xxx.com"
+ "<BR /><BR />";
String Output = Server.HtmlDecode(Input);
WebMail.SmtpServer = "mail.xxx.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = false;
WebMail.UserName = "xxx#xxx.com";
WebMail.Password = "xxxx";
WebMail.From = "xx#xxx.com";
WebMail.Send("xxx#xx.com", "You have a new domain order " + Model.DomainName,Output);
}
#{
String Inputorder = "Hi " + Model.FirstName
+ "<BR /><BR />"
+ "We are pleased to say your domain name " + Model.DomainName + "has been ordered."
+ "<BR /><BR />"
+ "Domain Details"
+ "<BR /><BR />"
+ Model.DomainName
+ "<BR /><BR />"
+ "Domain duration" + Model.DomainDuration
+ "<BR /><BR />"
+ "What to do next"
+ "<BR /><BR />"
+ "Server IP"
+ "<BR /><BR />"
+"Name Server 1:"
+ "<BR /><BR />"
+"Name Server 2:"
+ "<BR /><BR />"
+"MX:"
+ "<BR /><BR />"
+"A:"
+ "<BR /><BR />"
+"CNAME:"
+ "<BR /><BR />"
+ "PLEASE NOTE"
+ "<BR /><BR />"
+ "Please allow 24 hours for any DNS changes to take effect due to DNS caching by your ISP."
+ "<BR /><BR />"
+ "Many thanks for your order"
+ "<BR /><BR />"
+ "Kind regards"
+ "<BR /><BR />"
+ "xxx"
+ "<BR /><BR />"
+ "Email: support#xxx.com"
+ "<BR /><BR />";
String Outputorder = Server.HtmlDecode(Inputorder);
WebMail.SmtpServer = "mail.xxx.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = false;
WebMail.UserName = "xxx#xx.com";
WebMail.Password = "xxx";
WebMail.From = "sales#xx.com";
WebMail.Send( Model.EmailAddress, "Your new domain order: " + Model.DomainName,Outputorder);
}
<p>Thank you, almost done</p>
<p>Please click the purchase button to continue</p>
<input type ="submit" name="btsubmit" value= "Purchase"/>
I also have a controller called DomainsController
[HttpPost]
public ActionResult PostToPayPal(string item, string amount)
{
YippeeYay.Models.PayPal paypal = new Models.PayPal();
paypal.cmd = "_xclick";
paypal.business = ConfigurationManager.AppSettings["BusinessAccountKey"];
bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["UseSandbox"]);
if (useSandbox)
ViewBag.actionURL = "https://www.sandbox.paypal.com/cgi-big/webscr";
else
ViewBag.actionURL = "https://www.paypal.com/cgi-bin/webscr";
paypal.cancel_return = System.Configuration.ConfigurationManager.AppSettings["CancelURL"];
paypal.#return = ConfigurationManager.AppSettings["ReturnURL"];
paypal.notify_url = ConfigurationManager.AppSettings["NotifyURL"];
paypal.currency_code = ConfigurationManager.AppSettings["CurrencyCode"];
paypal.item_name = item;
paypal.amount = amount;
return View(paypal);
}
This section:
#using(Html.BeginForm("PostToPayPal", "Home"))
{
// Form goes in here
}
... is what's writing your tags, which need to contain your submit button. At the moment your submit button is outside this section, so the only things in your form are your two hidden fields. Move your submit button inside the form and it should work.
I have spent a while going over all of the examples on http://www.silverlight.net/learn/quickstarts/
And I'm still pretty lost about Silverlight. I'm not understanding exactly how it gets 'on' to the website. Like... is there any kind of tutorial that shows how you make an HTML webpage that retrieves a silverlight page and displays it, so you can work with it?
All I've had to work with so far are the default generated .aspx files, which don't really tell me much. And even using the default 'MVC Application' generator from Visual Studio is kind of cloudy and fuddled up.
I've done some google searches and glanced around at references, but maybe I'm just kind of dumb. I'm just not getting where it all 'comes together', so to speak. Any hints? Or am I just beyond learning?
The short answer is that you include Silverlight applications in a web page by using an object tag in HTML. The web browser is then responsible for loading the silverlight application similar to the way it loads Flash applications. Check out these quickstarts for a more detailed explanation. Don't be discouraged, this is a new concept to a lot of developers :).
Here is an example of a Silverlight application being embedded in a web page:
<body>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2,"
type="application/x-silverlight-2"
width="100%" height="100%">
<param name="source" value="HelloWorld.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50401.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0"
style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376"
alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object>
<iframe id="_sl_historyFrame"
style="visibility:hidden;height:0px;width:0px;border:0px">
</iframe>
</div>
</form>
</body>
Here is the Microsoft tutorial on Embedding Silverlight into HTML. The .xap is the equivalent to Jnlp for modern applets and .swf for Flash. The parameters can control the code and can also be updated via Javascript. The silverlight plugin within the browser executes the application code. HTML just holds it in place.
Just create a Silverlight Application and choose for it to create aHost the Silverlight Application in a Web site.
It will create a project that generates the page that contains silverlight object that loads the xap file on the client.
The xap file is located in the ClientBin, the xap file is the Silverlight application.
As long as you point the object source <param> to the path of the xap file, it should load the respective Silverlight App.
The project it creates:
Example aspx page:
<%# Page Language="C#" AutoEventWireup="true" %>
<!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 runat="server">
<title>SilverlightApplication1</title>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
#silverlightControlHost {
height: 100%;
text-align:center;
}
</style>
<script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript">
function onSilverlightError(sender, args) {
var appSource = "";
if (sender != null && sender != 0) {
appSource = sender.getHost().Source;
}
var errorType = args.ErrorType;
var iErrorCode = args.ErrorCode;
if (errorType == "ImageError" || errorType == "MediaError") {
return;
}
var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n" ;
errMsg += "Code: "+ iErrorCode + " \n";
errMsg += "Category: " + errorType + " \n";
errMsg += "Message: " + args.ErrorMessage + " \n";
if (errorType == "ParserError") {
errMsg += "File: " + args.xamlFile + " \n";
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
else if (errorType == "RuntimeError") {
if (args.lineNumber != 0) {
errMsg += "Line: " + args.lineNumber + " \n";
errMsg += "Position: " + args.charPosition + " \n";
}
errMsg += "MethodName: " + args.methodName + " \n";
}
throw new Error(errMsg);
}
</script>
</head>
<body>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/SilverlightApplication1.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="3.0.40818.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</form>
</body>
</html>