Hello, I've been trying to do a POSTS rating system for a few days, I see several tutorials talking about this, everyone uses ajaxtoolkit, I downloaded ajaxtoolkit, I installed, I did as I say, but the stars do not appear in the post, is a transparent space with clickable things, but without the stars!
CSS CODE:
.starempty {
background-image: url("https://i.imgur.com/Y6T8zFv.png");
width: 50px;
height: 50px;
}
.starfilled {
background-image: url("https://i.imgur.com/rqzO2MZ.png");
width: 50px;
height: 50px;
}
.starwaiting {
background-image: url("https://i.imgur.com/8uDtWlX.png");
width: 50px;
height: 50px;
}
ASPX CODE:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" CurrentRating="1" MaxRating="5"
StarCssClass="starempty" FilledStarCssClass="starfilled"
WaitingStarCssClass="starwaiting" EmptyStarCssClass="starempty"
runat="server" AutoPostBack="true">
</ajaxToolkit:Rating>
</ContentTemplate>
</asp:UpdatePanel>
HOW IT APPEARS ON THE PAGE:
PAGE DONT APEAR STARS!
if they do not know how to solve it, is there any other framework something like this to do a rating system?
Try using local images and remember to put no-repeat:
.starEmpty{
background-image: url(images/starempty.gif);
width: 50px;
height: 50px;
background-position: 0px 0px;
background-repeat: no-repeat;
}
Related
I am using the web application template that comes with visual studio. I have added a nested master page that splits the main content into two other content place holders, both of which are wrapped in divs that have css styling applied to them in an attempt to control their widths. One is used as the main content area for each page that inherits from this nested master page and, the other content place holder is used as a side panel that can be be expanded and collapsed left to right. This side panel will be persistent across most pages. That is why its in a content place holder so that in a page that doesnt need it can create custom content and then just leave it blank or use other data. This functionality has been achieved with the collapsible panel extender from ajax but, the size of the main content area is has a locked width. In my css I set max-width and min-width on the main content area but it only sets it to the min-width. Upon reading css documentation I have discovered that the min-width property overrides the max-width and width properties. My question is How do I get the main content area to be 95% in width when the side panel is collapsed and 75% in width when the side panel is expanded? I've tried to include as much relevant information as I could think of but if more is needed I will gladly provide it.
The relevant markup from my nested master page
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<div style="width: 100%; height: 100%;">
<div class="leftSidePanel">
<asp:ContentPlaceHolder ID="LeftSidePanelContent" runat="server">
<asp:Panel ID="Panel2" runat="server" CssClass="collapseLeftSidePanelHeader" >
<div style="padding: 5px; cursor: pointer; vertical-align: middle;">
<asp:ImageButton ID="Image1" runat="server" ImageUrl="~/Images/CollapsiblePanel/expand_blue.jpg" AlternateText="(Show Details...)" />
</div>
</asp:Panel>
<asp:Panel ID="Panel1" runat="server" CssClass="collapseLeftSidePanel" >
<br />
<asp:Label ID="Label1" runat="server" Text="MY PANEL"></asp:Label>
</asp:Panel>
<ajax:collapsiblepanelextender ID="cpeLeftSidePanel" runat="Server"
ExpandedSize="250"
CollapsedSize="0"
ExpandDirection="Horizontal"
TargetControlID="Panel1"
ExpandControlID="Panel2"
CollapseControlID="Panel2"
Collapsed="True"
TextLabelID="Label1"
ImageControlID="Image1"
ExpandedImage="~/Images/CollapsiblePanel/collapse_blue.jpg"
CollapsedImage="~/Images/CollapsiblePanel/expand_blue.jpg"
SuppressPostBack="true" />
</asp:ContentPlaceHolder>
</div>
<div class="mainPanel">
<asp:ContentPlaceHolder ID="MainPanelContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
The relevant css: the width for the collapse panel is set in the collapsible panel extender
.main
{
padding: 0em 1em;
margin: 1em;
width: 100%;
min-height: 420px;
border: thin solid black;
}
.mainPanel{
max-width: 90%;
min-width: 75%;
height: 100%;
float:right;
border: thin solid green;
}
.leftSidePanel{
min-width: 0;
max-width: 20%;
height: 100%;
float: left;
border: thin solid blue;
}
.collapseLeftSidePanelHeader{
width:30px;
height:100%;
background-repeat:repeat-y;
background-color: AliceBlue;
font-weight:bold;
float: right;
}
.collapseLeftSidePanel {
background-color:black;
overflow:hidden;
width:0;
height: 100%;
}
I just realized that I could possibly solve this by adding a second collapse panel extender and set it's target control id property to the main panel and have its trigger be the header of the side panel. This way when the side panel is expanded the main panel will collapse and vice versa. I could then use the expand and collapsed sizes to set the 75% and 95% values of the main panel. This seems like a hack to me and i would prefer a more pragmatic solution.
I want to upload a file and display the contents of that file in a grid using a FileUpload and a button control .But i need to do both the events in a single button click .I tried to Hide the FileUpload control but this doesn't work that well.
Following are the css style definitions i tried to apply :
<div style="height: 89px; width: 620px; position: relative; top: 226px; left: 229px; overflow:hidden">
<asp:FileUpload ID="FileUpload1" runat="server"
Style=" top:1px; left:-10px; width: 265px; position: relative; height: 26px; opacity: 0; filter: alpha(opacity=0)"
Font-Size="30pt" />
<asp:Button ID="Button1" runat="server" Text="Choose file.."
Style="top: -5px; left:-265px; z-index: -1; width: 251px; position: relative;"
Height="22px" />
</div>
This doesn't seem to serve my purpose.
Is there any way that will allow me to browse the file and display it in single button click?
Maybe this code will help
uploadButton.Attributes.Add("style", "visibility:hidden");
inputFile.Attributes.Add("onchange", "var uploadControl = document.getElementById('" + uploadButton.ClientID + "'); uploadControl.click();");
I am using rating control which is present in ASP.NET AJAX control toolkit. I have following questions.
It doesn't show up anything if I drag the control unto the page
CSS doesn't help either
How do I save the rating value in database
Thank you very much.
CSS
.ratingStar
{
font-size: 0pt;
width: 12px;
height: 12px;
cursor:pointer;
background-repeat: no-repeat;
}
.filledRatingStar
{
background-image: url(images/Star_filled.gif);
}
.emptyRatingStar
{
background-image: url(images/Star_empty.gif);
}
ASPX:
<asp:Rating ID="Rating2" runat="server" CurrentRating="1" MaxRating="6" StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
RatingAlign="Vertical">
</asp:Rating>
Rating is not showing up:
You're missing the style for savedRatingStar
More importantly, because you've set RatingAling="Vertical" you must specify display:block; for ratingStar
Change your code as follows and it will work:
CSS:
<style type="text/css">
.ratingStar
{
font-size: 0pt;
width: 12px;
height: 12px;
cursor: pointer;
background-repeat: no-repeat;
display: block;
}
.filledRatingStar
{
background-image: url(images/Star_filled.gif);
}
.emptyRatingStar
{
background-image: url(images/Star_empty.gif);
}
.savedRatingStar
{
/*change this to your image name*/
background-image: url(images/Saved_star.gif);
}
</style>
ASPX:
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Rating ID="Rating2" runat="server" CurrentRating="1" MaxRating="6" StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar" FilledStarCssClass="filledRatingStar" EmptyStarCssClass="emptyRatingStar"
RatingAlign="Vertical" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="SubmitRating" />
</form>
Saving the rating to the database:
The rating is available via the CurrentRating property of the Rating control, simply access it in code and insert it into the db (there are literally hundreds of examples on the net how to do this, I trust you'll be able to find your way from here)
protected void SubmitRating(object sender, EventArgs e)
{
int rating = Rating2.CurrentRating;
//Submit to database...
}
This is driving me mental!!!
Ok, I have the following scenario - ModalPopupExtender used to display an UpdateProgress panel when AJAX is running. So I have the following:
<asp:Panel ID="panelUpdateProgress" runat="server" CssClass="updateProgress" >
<asp:UpdateProgress ID="UpdateProg1" DisplayAfter="2" runat="server" ClientIDMode="Static">
<ProgressTemplate>
<div style="position: relative; top: 40%; text-align: center;">
<asp:Image ID="Image1" runat="server" Style="border: 0px; vertical-align: middle;
padding-bottom: 4px;" ImageUrl="~/Images/Refresh.gif" />
<asp:Label ID="Label2" runat="server" Style="border: 0px; vertical-align: middle;
margin-left: 7px" Text="Refreshing data, please wait..."></asp:Label>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalProgress" runat="server" TargetControlID="panelUpdateProgress"
BackgroundCssClass="modalBackground" PopupControlID="panelUpdateProgress">
</ajaxToolkit:ModalPopupExtender>
Javascript to fire the thing when AJAX kicks ins:
<script type="text/javascript" language="javascript">
var ModalProgress = '<%= ModalProgress.ClientID %>';
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginReq);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endReq);
function beginReq(sender, args) {
// shows the Popup
$find(ModalProgress).show();
}
function endReq(sender, args) {
// Hides the Popup
$find(ModalProgress).hide();
}
</script>
With the styling of :
<style type="text/css">
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=50);
opacity: 0.50;
}
.updateProgress
{
float: right;
border-width: 1px;
border-style: solid;
background-color: #FAFAD2;
width: 250px;
height: 100px;
}
</style>
However, I cannot for the life of me get the updateProgress to float right or adjust position (just as an example).
Using the developer tools, I can see that some sort of inline style overides the CSS style.
How on earth can I get, for example, my updateprogress to float right?
If you're fighting against inline styles that you have no control over, this is one of those rare cases where the use of !important is actually justified:
Give this a try:
.updateProgress
{
float: right !important;
/* etc. */
}
If this doesn't work, try adding a clear:right, or using a more specific selector like:
#someElement .updateProgress {}
EDIT: Specificity in CSS selectors won't help against inline styles, so ignore that as a possible solution.
well I've ditch the style sheet and run with this:
<asp:UpdateProgress ID="UpdateProg1" DisplayAfter="2" runat="server" ClientIDMode="Static">
<ProgressTemplate>
<div style="float: right; border-width: 1px; border-style: solid; background-color: #FAFAD2;
width: 250px; height: 100px;">
<div style="position: relative; top: 40%; text-align: center;">
<asp:Image ID="Image1" runat="server" Style="border: 0px; vertical-align: middle;
padding-bottom: 4px;" ImageUrl="~/Images/Refresh.gif" />
<asp:Label ID="Label2" runat="server" Style="border: 0px; vertical-align: middle;
margin-left: 7px" Text="Refreshing data, please wait..."></asp:Label>
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
It does the business so I'm happy for now :D
How do I add css for the Panle and the div tag, I am new to this I tried many ways but could not make it to work. How should I add css for individual Panel and individual Div tag. Thanks
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
<link href="Styles/AboutUs.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<asp:Panel ID="Panel2" runat="server" >
<div id="main">
</div>
</asp:Panel>
</asp:Content>
CSS:
----
.Panel2
{
position: relative;
top: -11px;
left: -20px;
height: 450px;
width: 928px;
}
.main
{
position: relative;
top: 17px;
left: 154px;
height: 110px;
width: 691px;
}
For this HTML
<asp:Panel ID="Panel2" runat="server" >
<div id="main">
</div>
</asp:Panel>
Change it to (see the change in BOLD)
<asp:Panel ID="Panel2" runat="server" **CssClass="pnlCSS"**>
<div id="main">
</div>
</asp:Panel>
and the css should be
#main
{
position: relative;
top: 17px;
left: 154px;
height: 110px;
width: 691px;
}
.pnlCSS
{
// CSS for panel here
}
If you what to use Ids instead of CssClass you will have to change your ClientIDMode="Static":
<asp:Panel ID="Panel2" ClientIDMode="Static" runat="server" >
<div id="main">
</div>
</asp:Panel>
What you need to do is look at the div and panel class in Firebug - when using ASP.NET Master pages, it will append certain things to your specified class; it will look something like #ct100_MainContent etc etc.
Again, take a look at Firebug and see what the div is being written to the browser as, and update that in your CSS.
You can use the CssClass property to define a css class for you panel div.
<asp:Panel ID="Panel2" runat="server" CssClass="myClass">
</asp:Panel>
And then use this class in your css:
.myClass {
position: relative;
top: -11px;
left: -20px;
height: 450px;
width: 928px;
}
Use
#main
{
position: relative;
top: 17px;
left: 154px;
height: 110px;
width: 691px;
}
and add CssClass="Panel2" to the panel