asp.net profiles - asp.net

I have this page called profile. The time is wrong when I run the application. Can someone help me correct the time to the right format?
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<strong>To View Profiles You Have to Register Or </strong> <asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/Account/Login.aspx" Font-Size="Large" Font-Bold="True">Login</asp:HyperLink>
</AnonymousTemplate>
<LoggedInTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [UserId], [UserName], [LastActivityDate] FROM [vw_aspnet_Users]"></asp:SqlDataSource><br />
<div align="center">
<h1 style="text-align:center;
font-size: x-large;
font-weight: bold;
border: solid 2px gold;
background-color: #ffc;
padding: 5px;
margin-bottom: 15px;
width: 66%;">
Members Of Living To Please The Lord World(Ephesians 5:10) !
</h1>
</div><br />
<div style="padding-left:10px" align="center">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<a id="A1" href=<%#"~/Profiles.aspx?UserId=" & Eval("UserId").ToString %> runat="server" style="font-size:large;">
<%#Eval("UserName") %>
</a>
Last Visted On : <%# Eval("LastActivityDate")%>
<br />
</ItemTemplate>
</asp:Repeater>
</div>
</LoggedInTemplate>
</asp:LoginView>

Ok, if this is really MVC, it should look like this: <%= Model.LastActivityDate.ToShortDateString() %> But I think you have ASP.NET Forms here.

Related

how to give marquee to a hyperlink in repeater control

I want to show some scrolling(marquee) link in my Website form to
display data I am using repeater control.but when i am trying to give
marquee to the repeater it doesn't give me output How I give marquee
Please help. My code:
<div id="calendar1">
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CBMIAConnectionString %>"
SelectCommand="SELECT Event FROM [Home_EventLink]"></asp:SqlDataSource>
<table id="Head_Meeting">
<tr>
<td style="font-size: large; font-weight: bold; font-family: Arial, Helvetica, sans-serif; text-transform: capitalize; color: white;">&nbsp&nbsp<i class="fas fa-calendar-alt" style="font-size: 25px; color: white"></i>&nbsp Upcoming Meetings</td>
</tr>
</table>
<br />
<div id="Meeting_Event" padding-left="5px" padding-right="5px">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" class="hyperlink" Text='<%# Eval("Event") %>' href="home.aspx" runat="server" /><br />
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:Repeater>
</div>
</div>
THIS MAY HELP
<marquee id="MyMovingText" style="width: 80%" scrollamount="5" onmouseover="stop();" onmouseout="start();" runat="server" direction="left">
<asp:datalist RepeatDirection="Horizontal" ID="rptbreaknews" runat="server">
<ItemTemplate>
<a class="readmore" target="_blank" href='<%#"details.aspx?Id="+Eval("Id") %>'>
<h3><asp:Label ID="lbltext" Text='<%#Eval("NewNewsTitle") %>' runat="server"></asp:Label></h3>
</a>
</ItemTemplate>
</asp:datalist>
</marquee>
You can use marquee like this. And do not use class and href within an aspnet Control but use the correct properties like CssClass and NavigateUrl
<marquee id="MyMovingText" direction="left" scrollamount="10">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div class="scroll-item">
<asp:HyperLink ID="HyperLink1" CssClass="hyperlink" Text='<%# Eval("Event") %>'
NavigateUrl="/home.aspx" runat="server" />
</div>
</ItemTemplate>
</asp:Repeater>
</marquee>
<style>
.scroll-item {
float: left;
margin-right: 50px;
}
</style>

Where in this markup would I insert <script> tags?

Here is the markup that I have:
<%# Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="AddSale.aspx.vb" Inherits="Default2" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
Add New Sale
</h2>
<p>
Please use the buttons and controls below to add a new sale for this lot to the dealership's database.
</p>
<div style="height: 180px; width: 300px">
<asp:Label ID="Label1" runat="server" style="margin:0 auto; display:inline-block" Text="Salesperson:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" style="float:right; margin:0 auto; display:inline-block"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label2" runat="server" style="margin:0 auto; display:inline-block" Text="VIN:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" style="float:right; margin:0 auto; display:inline-block"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label3" runat="server" style="margin:0 auto; display:inline-block" Text="Sale Price:"></asp:Label>
<asp:TextBox ID="test" runat="server" style="float:right; margin:0 auto; display:inline-block"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label4" runat="server" style="display:inline-block" Text="MSRP:"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" style="float:right; display:inline-block;"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label5" runat="server" style=" display:inline-block;" Text="Commission Rate:"></asp:Label>
<asp:TextBox ID="TextBox4" runat="server" style="float:right; display:inline-block;"></asp:TextBox>
<br />
<br />
</div>
<p>
<asp:Button ID="btntest" runat="server" Text="Add Record"/>
</p>
</asp:Content>
I can't seem to figure out how I would add a <script> tag in the markup, everything I try gives me an error.
I want to add a script that includes a function that will reject empty or badly-written boxes using regex. I notice that I don't have <html> or <head> or <body> tags on my code. Will I use those? Are those necessary at all? Where would I add it on here? By the way, this is not the master page.
If you only need the javascript function on this page, try adding the script tag inside of your HeadContent tag to get yourself started.
If you put the script in the master page, then that script will load and be available on every page that uses that master page.
It should be noted that many prefer their JavaScript in a separate file which you can then reference with a link tag within the head tag. Mason's link in his comment provides good information.

How can i do the following in asp.net?

I am trying to create a simple course registration web site in asp.net. I am now creating a page that allows a user to create a course. Here is the related user interface:
And here is the code of this page:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="AdminCreateCourse.aspx.cs"
Inherits="AdminCreateCourse" %>
<!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></title>
<style type="text/css">
.style1
{
font-size: x-large;
}
.style3
{
font-size: small;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="style1">
<strong>Create Course</strong></div>
<p>
</p>
<p>
Instructor Name:
<asp:DropDownList ID="dInstructorSelect" runat="server" DataSourceID="SqlDataSource1"
DataTextField="FullName" DataValueField="FullName" Height="16px" Width="202px">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [Name] + ' ' + [Surname] as FullName FROM [InstructorTable] ORDER BY [Name]">
</asp:SqlDataSource>
</p>
<p>
Course Name:
<asp:TextBox ID="tCourseName" runat="server"></asp:TextBox>
</p>
<p>
Course ID<br />
(Subject/Course):
<asp:DropDownList ID="dSubject" runat="server" Width="70px">
<asp:ListItem>CS</asp:ListItem>
<asp:ListItem>CULT</asp:ListItem>
<asp:ListItem>ECON</asp:ListItem>
<asp:ListItem>IS</asp:ListItem>
<asp:ListItem>MAN</asp:ListItem>
<asp:ListItem>SPS</asp:ListItem>
<asp:ListItem>VACD</asp:ListItem>
<asp:ListItem>BIO</asp:ListItem>
<asp:ListItem>EE</asp:ListItem>
<asp:ListItem>EL</asp:ListItem>
<asp:ListItem>MAT</asp:ListItem>
<asp:ListItem>ME</asp:ListItem>
<asp:ListItem>MS</asp:ListItem>
<asp:ListItem>TE</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="tCourse" runat="server" Width="70px"></asp:TextBox>
</p>
<p>
CRN:
<asp:TextBox ID="tCRN" runat="server"></asp:TextBox>
</p>
<p>
Level:
<asp:DropDownList ID="dLevel" runat="server">
<asp:ListItem>Undergraduate</asp:ListItem>
<asp:ListItem>Graduate</asp:ListItem>
</asp:DropDownList>
</p>
<p>
Term:
</p>
<p>
Course Description:
</p>
<p>
<asp:TextBox ID="tCourseDescription" runat="server" Height="138px" Width="406px"></asp:TextBox>
</p>
<p>
Capacity:
<asp:TextBox ID="tCapacity" runat="server"></asp:TextBox>
</p>
<p>
Class Hour and Day: <span class="style3">Start Hour:
<asp:DropDownList ID="dHourStart" runat="server">
<asp:ListItem>8:40</asp:ListItem>
<asp:ListItem>9:40</asp:ListItem>
<asp:ListItem>10:40</asp:ListItem>
<asp:ListItem>11:40</asp:ListItem>
<asp:ListItem>12:40</asp:ListItem>
<asp:ListItem>13:40</asp:ListItem>
<asp:ListItem>14:40</asp:ListItem>
<asp:ListItem>15:40</asp:ListItem>
<asp:ListItem>16:40</asp:ListItem>
<asp:ListItem>17:40</asp:ListItem>
<asp:ListItem>18:40</asp:ListItem>
<asp:ListItem>19:40</asp:ListItem>
</asp:DropDownList>
End Hour:
<asp:DropDownList ID="dHourEnd" runat="server">
<asp:ListItem>10:30</asp:ListItem>
<asp:ListItem>11:30</asp:ListItem>
<asp:ListItem>12:30</asp:ListItem>
<asp:ListItem>13:30</asp:ListItem>
<asp:ListItem>14:30</asp:ListItem>
<asp:ListItem>15:30</asp:ListItem>
<asp:ListItem>16:30</asp:ListItem>
<asp:ListItem>17:30</asp:ListItem>
<asp:ListItem>18:30</asp:ListItem>
<asp:ListItem>19:30</asp:ListItem>
<asp:ListItem>20:30</asp:ListItem>
<asp:ListItem>9:30</asp:ListItem>
</asp:DropDownList>
Day:</span> <asp:DropDownList ID="dDay" runat="server">
<asp:ListItem>Monday</asp:ListItem>
<asp:ListItem>Tuesday</asp:ListItem>
<asp:ListItem>Wednesday</asp:ListItem>
<asp:ListItem>Thursday</asp:ListItem>
<asp:ListItem>Friday</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="bAddCourseHour" runat="server" Text="Add" OnClick="bAddCourseHour_Click" />
</p>
<p>
Prerequisites:
<asp:TextBox ID="tPreq1" runat="server" Width="100px"></asp:TextBox>
<asp:TextBox ID="tPreq2" runat="server" Width="100px"></asp:TextBox>
<asp:TextBox ID="tPreq3" runat="server" Width="100px"></asp:TextBox>
</p>
<asp:Button ID="bSubmit" runat="server" Text="Submit" OnClick="bSubmit_Click" />
<asp:Button ID="bClear" runat="server" Text="Clear" OnClick="bClear_Click" />
</form>
</body>
</html>
My question is, a course may be held in more than one different days, but my interface only allows one day. Should i handle this using AJAX, or is there any other way? If i should use ajax, how can i do this?
Thanks
I assume you are looking for a way to allow multiple selections on the "Day" field. If so, you have at least couple of options here:
1) Either use the CheckBoxList Control (http://msdn.microsoft.com/enIN/library/8bw4x4wa(v=vs.90).aspx).
2) Or, if real estate is an issue, use the DropDownCheckBoxes control at http://dropdowncheckboxes.codeplex.com/

Divs not working as expected

I am trying to create the rows of controls. Basically it is for filtering a search. There are six controls in each row, 3 labels and 3 dropdownlists/textboxes. I have a div which creates rows and the first row turns out great but the rest is really weird.
The markup is the following
<div class="fullRow" style="margin-top:10px">
<asp:Label ID="FilterDepartmentLabel" AssociatedControlID="FilterDepartment" runat="server" Text="Department" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterDepartment" runat="server" CssClass="aThirdInput" />
<asp:Label ID="FilterCardStatusLabel" AssociatedControlID="FilterCardStatus" runat="server" Text="Status" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterCardStatus" runat="server" CssClass="aThirdInput" />
<asp:Label ID="FilterCardBehaviorLabel" AssociatedControlID="FilterCardBehavior" runat="server" Text="Behavior" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterCardBehavior" runat="server" CssClass="aThirdInput" />
</div>
<div class="fullRow" style="margin-top:10px">
<asp:Label ID="FilterCarPlateLabel" AssociatedControlID="FilterCarPlate" runat="server" Text="Car Plate" CssClass="aThirdLabel"></asp:Label>
<asp:TextBox ID="FilterCarPlate" runat="server" CssClass="aThirdInput"></asp:TextBox>
<asp:Label ID="FilterCardNoLabel" AssociatedControlID="FilterCardNo" runat="server" Text="Car No" CssClass="aThirdLabel"></asp:Label>
<asp:TextBox ID="FilterCardNo" runat="server" CssClass="aThirdInput"></asp:TextBox>
<asp:Label ID="FilterRuleSetCodeLabel" AssociatedControlID="FilterRuleSetCode" runat="server" Text="Rule Set" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterRuleSetCode" runat="server" CssClass="aThirdInput" />
</div>
<div class="fullRow" style="margin-top:10px">
<asp:Label ID="FilterDriverLastNameLabel" AssociatedControlID="FilterDriverLastName" runat="server" Text="Driver Lastname" CssClass="aThirdLabel"></asp:Label>
<asp:TextBox ID="FilterDriverLastName" runat="server" CssClass="aThirdInput"></asp:TextBox>
<asp:Label ID="FilterCardTypeLabel" AssociatedControlID="FilterCardType" runat="server" Text="Type" CssClass="aThirdLabel"></asp:Label>
<asp:DropDownList ID="FilterCardType" runat="server" CssClass="aThirdInput" />
</div>
And here is the css
.fullRow
{
width: 100%;
display:block;
}
.aThirdLabel
{
width: 15%;
float: left;
font-size:small;
height: 22px;
}
.aThirdInput
{
width: 15%;
float: left;
}
Actually, even though this looks good in design view of VS2010, when its loaded in the browser, its a mess.
Thanks
EDIT: The answer is in the comment huMpty duMpty made.
Add <div style="clear:both;"></div> after each row.

How to align objects vertically in ASP.NET?

I have been messing around with asp.net for awhile now and always have issues aligning objects with various heights on the same row. For example, in this case, I have a search label, a text field, then a image button. What is the "proper way" to get these three items to align properly?
My existing code:
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Panel VerticalAlign="Center" runat="server">
<asp:Label ID="Label1" runat="server" Font-Size="X-Large" Text="Search Tests:"></asp:Label>
<asp:TextBox ID="searchTextBox" runat="server" Font-Size="X-Large"
Height="30px" style="margin-left: 13px; margin-top: 0px" Width="219px"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" Height="45px"
ImageUrl="~/Images/SearchButton.PNG" style="margin-left: 18px; margin-top: 0px"
Width="95px" />
</asp:Panel>
</asp:Content>
The easiest is using CSS or tables. I put a div around with a height and vertical align to the top. CSS Reference
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Panel ID="Panel1" VerticalAlign="Center" runat="server">
<div style="height: 40px; vertical-align: top">
<div style="padding-top: 10px; float:left;">
<asp:Label ID="Label1" runat="server" Font-Size="X-Large" Text="Search Tests:"></asp:Label>
</div>
<div style="padding-top: 5px; float:left;">
<asp:TextBox ID="searchTextBox" runat="server" Font-Size="X-Large" Height="30px"
Style="margin-left: 13px; margin-top: 0px" Width="219px"></asp:TextBox>
</div>
<div style="padding-top: 5px; float:left;">
<asp:ImageButton ID="ImageButton2" runat="server" Height="45px" ImageUrl="~/Images/SearchButton.PNG"
Style="margin-left: 18px; margin-top: 0px" Width="95px" />
</div>
</div>
</asp:Panel>
</asp:Content>
i had the same problem and i think that using a table or a div only to align the Textbox it's excessive.
I solved simply:
<asp:TextBox ID="TextBox2" runat="server" Width="60px"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/imatges/imgNou.png"
CssClass="style3" ImageAlign="AbsBottom" />
And adding the margin-top in Design view, the IDE added:
.style3
{
margin-top: 6px;
}

Resources