Quick question. I am dynamically creating some buttons and basically want to add a background image to them in the code behind. Can someone tell me how its supposed to look like? I want to use the Button.Style.Add().
I tried Button.Style.Add("background-image","url(~/Uploads/Steak.jpg)"); but it did not work.
please use following code:
Button.Style.Add("background-image","url('~/Uploads/Steak.jpg')");
Add single quotes to the url
string strimgpath = "Uploads/Steak.jpg";
String strImgLocation = "url('" + strimgpath + "')";
idimage.Style.Add("background-image", strImgLocation);
Related
when checked checkbox get checkbox value in angular js how can do please help me any one, i teken code from js fiddle add css and removed boostrap.
I am trying to display checked checkbox vlaues in my project how can do.please help me any once. I tryed that code i kept in js fiddle "https://jsfiddle.net/ramesh_bogandla/22et6sao/871/" please help me any one
$("input:checkbox").click(function() {
var output = "";
$("input:checked").each(function() {
output += $(this).next('span').text() + ", ";
});
$(".textboxclass here").val(output.trim().slice(0,-1));
});
Try It Once this is an example code for idea.
Check edited fiddle, just use {{example14model}} or more detailed access to this variable in template
https://jsfiddle.net/22et6sao/872/
Hi I am trying to get an image in an export to word.
I designed in html using string builder but i am not getting image.
My code is below. var image contains say 'Penguin.jpg'
StringBuilder head = new StringBuilder();
head.Append(#"<img src='"+Server.MapPath("")+"/img/"+image+"' alt='sdsdsd' height='42' width='42' />");
hdnOrg.Value = head.ToString();
How can i correct problem?
You are trying to assign the html to hidden field that is not the correct way, use div instead. You can assign html to InnerHtml of div. Do not forget to make div runat="server" so that you can access it in code behind. You can use also use Label or Panel etc as well instead of div.
Html
<div id="divForImg" runat="server" ></div>
Code behind
divForImg.InnerHtml = head.ToString();
If you want to reach the root path for path then you can use / forward slash and you do not need physical path rather virtual path so do not use Server.MapPath
head.Append(#"<img src='/img/" + image+ "' alt='sdsdsd' height='42' width='42' />");
As an additional note, using StringBulider here does not make much sense here as you have only one Append call and doing string concatenation on to make the path.
You are creating the the image url in the wrong way.
Server.MapPath("") is not supposed to be executed like that, with no params.
This should solve your issue
strHTMLBuilder.Append(#"<img src='file://C:\Location\img.PNG'>");
So I have little issue with my title tag.
So I have some message like
IHaveSpacebars = I'd like to show you everything
I'm adding image via coffescript because I have to, but I think it wouldn't change a thing, so heres image code
<img src=\"#{url("/static/css/images/tick_shield.png")}\" style=\"margin-top:-6px\" title=" + i18n('IHaveSpacebars') + ">
i18n returns full string "I'd like to show you everything" so this is working well (checked via firebug).
So my issue: when I move mouse cursor over my image tick_shield.png it shows only I'd instead of I'd like to show you everything. I believe I messed up with this " + variable + " in title tag but I couldn't find anything else :/ examples that don't work:
title=i18n('IHaveSpacebars')
returns i18n('IHaveSpacebars') instead of txt
IHaveSpacebars = "I'd like to show you everything"
giving that one " " works, but that string is also used in other names (like column name) which will return column name with " ".
So do you guys (and girls:)) know how to write it correctly? I'm sure it's my fault with this " + . + " but couldn't find how to write it different.
Ok I found out a solution so maybe someone will find it helpful:
title="+"'"+i18n('IHaveSpacebars')+"'
The reason why it didn't work was that my original code title="+i18n('IHaveSpacebars')+" was returning
<img src="" title='I'd' like to show you everything>
while code above is returning
<img src="" title='I'd like to show you everything'>
Cheers ;)
So heres the code Im using:
endScreen.scorePrint.text = String(score);
endScreen.distancePrint.text = String(distance);
And it doesent show anything, while the very same code in other places in my app works, I tried to embed fonts and stuff but I still get blank space. what am I doing wrong?
EDIT:
endScreen is a MovieClip without AS linkage, its manipulated by .visible , scorePrint and distancePrint are a part of that MovieClip.
scorePrint and distancePrint are identical in all but names and are as following:
classic text -> dynamic text
Try
endScreen.scorePrint.text = "" + score;
if not, then does
trace("" + score);
show anything?
I fixed it, the problem was anti-aliasing. I changed from anti-aliasing for readability to device fonts. that fixed both fields.
Thanks for support :)
I have a sub that writes out a bunch of HTML inside of a literal control. Part of this HTML is an image that I would like to add an onclick event to. The onclick just needs to alert a string that I have available in the same sub. ONCE THE HTML GENERATING IS COMPLETE the string to return will also be complete. So it is at this point I would need to add the onlick event to the image. But how can I do so as it won't recognize the control at this point? Thanks guys.
/**** EDIT ****/
ok so, I changed things around and I just inserted the string for the image button last so that the string to return is complete. however when the html is inserted the string kind of screws it up because of punctuation. the string could contain any number of special characters :',;" etc.
here is the line of html in the vb.net codebehind
text = "<td style='background-color:#C8DBEC;width:31px;'><img style='cursor:pointer;' id='imgPrint' src='../images/Buttons/printerbtn.png' onclick='printTranscript(" + finalText + ");' /></td>"
so my question is.. how do I need to format the finalText so that it will pass through to the javascript call?
I think your code should look like this:
text = #"<td style='background-color:#C8DBEC;width:31px;'><img style='cursor:pointer;' id='imgPrint' src='../images/Buttons/printerbtn.png' onclick='printTranscript(""" + finalText + #""");' /></td>"
I put doublequotes before and after finalText variable (inside the brackets), otherwise its value would be parsed in javascript like a varible name. I also had to place # sign at the beginning of the both strings to be able to use doublequotes
(you can read more about it here: http://msdn.microsoft.com/en-us/library/362314fe%28v=vs.71%29.aspx)
Are you using JQuery? it makes it pretty simple
$('#target').html(""');
$('#imgPrint').click(function() { printTranscript(" + finalText + "); });
I Just love JQuery
I did not test but it'll be something like that
Just bind a click event to your image. Set your alert to the finalText and voila.
$("#imgPrint").click(alert(finalText));
OR
$("#imgPrint").click(printTranscript(finalText));
finalText can be stored as an alt or title on the image and then you can grab that with jQuery as well, or you can set it in a field with display none.
With the above code you don't need an onClick on the image.