I'm working on something but i'd like to know how to stop text from auto entering.
I don't use a break there so I don't really know what the problem is. I used something from overstack to show a div when you hover on it. Maybe this need's to be centered because the div wouldn't have the right position. I don't really know I'm pretty new to CSS.
My code looks like this:
C#
public string ToonGrenzenPerZoekwoord(string zoekwoord)
{
string list = "";/*"<h1> Resultaten via grenzen </h1> <br>";*/
foreach (DataTable table in _persistcode.SearchGrenzenByKeyword("%" + zoekwoord + "%").Tables)
{
foreach (DataRow row in table.Rows)
{
list += "<span class='t1'>" + row["Grens"].ToString() + ": <br>" + "</span>" + "<span class='t2'>" + row["Sanctie"].ToString() + "<br> <br>" + "Dit hoort thuis in de categorie: " + row["IDCategorieën"].ToString() + "</span>" + "<br>";
}
}
return list;
}
HTML & CSS
.infospan{
background: none repeat scroll 0 0 #F8F8F8;
border: 5px solid #DFDFDF;
color: #717171;
font-size: 13px;
height: 30px;
letter-spacing: 1px;
line-height: 30px;
margin: 0 auto;
position: relative;
text-align: center;
text-transform: uppercase;
top: -80px;
display:none;
padding:0 20px;
}
.infospan::after{
content:'';
position:absolute;
bottom:-10px;
width:10px;
height:10px;
border-bottom:5px solid #dfdfdf;
border-right:5px solid #dfdfdf;
background:#f8f8f8;
left:50%;
margin-left:-5px;
-moz-transform:rotate(45deg);
-webkit-transform:rotate(45deg);
transform:rotate(45deg);
}
p{
cursor:pointer;
}
p:hover span{
display:block;
}
<!--Resultaat-->
<div id="resultaat" runat="server" style="text-align: center; color: white; font-size: 24px;"></div>
I don't know about the css trick but i think this simple javascript code will help you :
$('your_class').bind('keypress', function(e){
if(e.keyCode == 13){
return false;
}
});
If you mean white space beneath your list items you should be careful with the <br>'s
Although I don't support the use of <br> in general, (see Is it sometimes bad to use <BR />?) you might want to try this:
public string ToonGrenzenPerZoekwoord(string zoekwoord)
{
string list = "";/*"<h1> Resultaten via grenzen </h1> <br>";*/
foreach (DataTable table in _persistcode.SearchGrenzenByKeyword("%" + zoekwoord + "%").Tables)
{
foreach (DataRow row in table.Rows)
{
list += "<p class='t1'>"; //using paragraph
list += row["Grens"].ToString();
list += ": <br>" + "</span>" + "<span class='t2'>";
list += row["Sanctie"].ToString() + "<br> <br>";
list += "Dit hoort thuis in de categorie: ";
list += row["IDCategorieën"].ToString();
list += "</p>"; //ommited final <br>
}
}
return list;
}
It might be even better to rule out all br's, but I'll need to be sure what your exact question is.
Side note: please be advised if somehow in your data, e.g.: row["Sanctie"] a value of
<script>alert('turtle`);</script>
is present, you'll find yourself having a hard time to 'shoo it away'.
Related
How to use ternary condition with style - url tag, between HttpContext.Current.Request.Url.Host and HttpContext.Current.Request.Url.Authority on .aspx page to (want to check is it localhost or not directly)?
Here is example:
"div style='<%= "height: 1115px; background-image: url(\"" + "http://" + HttpContext.Current.Request.Url.Host.ToString() +"ImagePath"); background-position: bottom center; background-repeat: no-repeat;" %>'"
I want to check if it is localhost then it will take Authority and if not then it must take Host.
this .aspx code (sorry, it's long, I couldn't break it into multiple without breaking syntax):
<div style='<%= "height: 1115px; background-image: url(\"http://" + (HttpContext.Current.Request.Url.Host.ToString().Contains("localhost") ? HttpContext.Current.Request.Url.Authority : HttpContext.Current.Request.Url.Host ) + "/" + "path/to/image.jpg" + "\"); background-position: bottom center; background-repeat: no-repeat;" %>'>my_div_content</div>
will produce this result:
<div style="height: 1115px; background-image: url("http://lc.host.com/path/to/image.jpg"); background-position: bottom center; background-repeat: no-repeat;">my_div_content</div>
given that your ImagePath variabl contains the real path to your image, you need to replace this line in the div:
+ "path/to/image.jpg" +
with this:
+ ImagePath +
Don't worry that both style=" and url(" contain ", it should work anyways. I confirmed this in Chrome.
HTH
Pseudo code:
HttpContext.Current.Request.Url.Contains("localhost") ? ... : ...
What I'd like to do is have something similar to what SO does on the main page:
So, what I did was add this code:
C# Code-Behind:
protected void LoadInterests()
{
//Fill Interests based on table values
string strSQL2 = "SELECT UM.MatchValue, DD.DDLValue FROM tmpUsermatch UM ";
strSQL2 = strSQL2 + "INNER JOIN (SELECT StoredValue, DDLValue FROM tmpDropdowns WHERE ddlName = 'ddlInterests') DD ";
strSQL2 = strSQL2 + "ON UM.MatchValue = DD.StoredValue ";
strSQL2 = strSQL2 + "WHERE MatchField = 'MatchInterests' AND UserID = '" + lblUserID.Text + "'";
using (var con = new SqlConnection(strCon1))
using (var adapter2 = new SqlDataAdapter(strSQL2, con))
{
DataTable dt2 = new DataTable();
adapter2.Fill(dt2);
foreach (DataRow row in dt2.Rows)
{
Label dynamicLabel = new Label();
dynamicLabel.ID = "lbl" + row["DDLValue"].ToString();
dynamicLabel.Text = row["DDLValue"].ToString();
dynamicLabel.CssClass = "lbl.interests";
div1.Controls.Add(dynamicLabel);
}
}
}
asp.net:
<div>
<asp:Panel ID="Panel1" runat="server" Height="100px" ScrollBars="Vertical" Style="float: left; margin-left: 1px; background-color:#f5f5f5" Width="807px" BorderColor="LightSteelBlue" BorderStyle="Solid" BorderWidth="1px">
<div id="div1" runat="server" class="clear" style="width:820px; border-width:1px; margin-left:20px"></div>
</asp:Panel>
</div>
CSS:
lbl.interests
{
background-color: #465c71;
/* background-color: white; */
border: 1px #4e667d solid;
color: white;
display: block;
line-height: 1.35em;
padding: 4px 20px;
text-decoration: none;
white-space: nowrap;
}
The end result is still this:
when I want it to look like this:
Any ideas on where I'm going wrong?
Change the line
dynamicLabel.CssClass = "lbl.interests";
to
dynamicLabel.CssClass = "lbl interests";
AND change CSS selector to
.lbl.interests
Remember . is used for selecting class name only in CSS, it will not be present in HTML, also if you specify just name in css like lbl you are referring to a TAG in HTML which is invalid tag according to HTML and also does match with the code.
My suggestion would be first write plain HTML and CSS and confirm your layout is working as expected, then generate the HTML with C#/ASP.Net
Refer the below link for help on CSS Selectors
W3Schools - CSS Selectors
First I will explain my scenario.
I have asp.net menu (dynamically created menu) and now I want to place push notification just like Facebook on my each menu option. I have designed it using CSS and put a label using jQuery.
if (res == "MenuIcons") {
$(this.parentElement).addClass('Notification');
var $label = $("<label ID=\"notificationlbl" + i + "\" style=\"position: absolute; margin-top: 2%; margin-left: -3.1%; margin-right:-3.3%; z-index: 99; color: white; font-size: 9px; font-family: Verdana; letter-spacing: -1px;\">").text('99');
$(this.parentElement.parentElement).append($label);
i++;
}
But I am totally confused that how to handle it using C# because I am unable to get the ID of the label created on run-time.
If you didn't understand please let me know and I will explain it more.
why don't you set a data attribute to each label, something like
var $label = $("<label data-element-type='notification' ID=\"notificationlbl" + i + "\" style=\"position: absolute; margin-top: 2%; margin-left: -3.1%; margin-right:-3.3%; z-index: 99; color: white; font-size: 9px; font-family: Verdana; letter-spacing: -1px;\">").text('99');
and then you can retrieve the whole collection with jQuery:
$("[data-element-type='notification']").each(function(){...});
Try adding runat="server" attribute in your label tag. You label tag id won't be available until runtime. So what you can do is search for the controllers by the id of your label. In code behind you can do as following
foreach(Contol c in this.Controls)
{
if(c.ID.contains("notificationlbl")
{
//your code
}
}
I have the following html code, which allow you to select Multiple files:
<input id="uploadFiles" type="file" name="myfiles" multiple="multiple" onchange="selectMulitableFiles(this)">
here is the onchange funcion:
function selectMulitableFiles(e) {
$.each(e.files, function () {
var tempelete = '<tr><td><img onload="loadImage(this);" alt="" src=' + this.name + ' style="border-style: solid; border-width: 1px; width: 60px; height: 60px;" /></td></tr>';
$("#tblImages tbody").append(tempelete);
});
}
What i am trying to achieve is to view all these selected images to the images that i generate and then write inside a control, but e.value will give you only the fake path.
Is what i am trying to do possible or not ?
here if ur solution
you need to use FileReader() to give image src ..
function selectMulitableFiles(e) {
$.each(e.files, function () {
var reader = new FileReader();
reader.onload = function (e) {
var tempelete = '<tr><td><img onload="loadImage(this);" alt="" src=' + e.target.result + ' style="border-style: solid; border-width: 1px; width: 60px; height: 60px;" /></td></tr>';
$("#tblImages tbody").append(tempelete);
}
reader.readAsDataURL(e.files[0]);
});
}
JSBIN Example
I would like to customize the asp:Calendar-Element the following way:
1) Each day has a dropwndown list wiith 6-7 phrases like (out of office, on holidays) and so on. and depending on which option you click, the color of that da changes. also, the selected optin should be saved to a database.
2) only certain users should be able to look at past months. For all other users, there should be no button for selecting previous months.
Is that possible with this calendar? Has anyone ever modified it in this way and can give me some tips? Or do I need to create such a calendar myself?
Thanks for your tips!
Yes can do with your asp.net calendar but you have do by customize your asp.net calendar with CSS as well as jQuery. I had also implemented in past with asp.net calendar. Below code is just for your help.
<style type="text/css">
.Calendar {border:none;}
.Calendar img{ border:none;}
.Calendar .Title {background-color:#7D9459;background-image:url(../Images/title_bg.gif);border: 1px solid black;border-bottom-width: 0px;}
.Calendar .Title td {font-family:verdana;font-size:11px;font-weight:bold;color:White;padding-top:1px;padding-bottom:1px;}
.Calendar .DayHeader {background-color:#E3E0CD;background-image:url(../Images/header_bg.gif);color:#504C39;font-family:Verdana;font-size:11px;text-align:center;border-top:solid 1px #FFFFFF; border-left:solid 1px #FFFFFF; border-bottom:solid 1px #ACA899;border-right:solid 1px #C6C1AC; padding: 4px; font-weight:normal;}
.Calendar .Day {width:90px; height:70px; text-align:center; vertical-align:top; font-family:Verdana; font-size:11px; color:Black; background-color:#FFFFFF; border:solid 1px #C6C1AC; padding:2px;}
.Calendar .OtherMonthDay {background-color:#F5F3E5;}
</style>
<asp:Calendar ID="MeetingCalendar" runat="server" CssClass="Calendar" TitleStyle-BackColor="Transparent"
CellPadding="0" BorderWidth="0px" Width="" DayNameFormat="Full" OnDayRender="MeetingCalendar_DayRender"
TitleStyle-CssClass="Title" DayHeaderStyle-CssClass="DayHeader" DayStyle-CssClass="Day"
DayStyle-Width="90px" OtherMonthDayStyle-CssClass="Day OtherMonthDay" NextMonthText="<img src='../Images/next_wht.gif' alt='' style='float:right;' />"
PrevMonthText="<img src='../Images/prev_wht.gif' alt='' style='float:left;'/>"
onvisiblemonthchanged="MeetingCalendar_VisibleMonthChanged">
</asp:Calendar>
protected void MeetingCalendar_DayRender(object sender, DayRenderEventArgs e)
{
string dayNumber = e.Day.Date.Day.ToString();
e.Cell.Text = dayNumber + "<br />";
e.Cell.Text += "<div align='center'>";
e.Cell.Text += " <a href='DailyMeetings.aspx?id=10' title='Day has meeting(s) scheduled.'>";
e.Cell.Text += " <img src='../Images/meeting.gif' height='25' width='25' alt='' border='0' />";
e.Cell.Text += " </a>";
e.Cell.Text += "</div>";
}