 |
|
 |
Hi
I am new to asp programming, can I have a some working sample code for this control, as I am not sure how to call events and how to pass selected values.
any feedback will really help me to understand the control easily.
Response appreciated.
Regards,
|
|
|
|
 |
|
|
 |
|
 |
What modifications are required to use this control inside od DataList's item to select/edit DataList items? I would like to make DataList's item enter it's edit mode when a user clicks on ASPnetRater control that is inside of ItemTemplate. Something like this (this acctualy doesn't fire onItemCommand and doesn't make DataList's item enter editing mode):
<asp:DataList ID="themes" runat="server" onitemcommand="themes_ItemCommand">
<ItemTemplate>
<cc:Rater
ID="Rater1"
runat="server"
Value='0'
MaxValue="5"
ToolTip="Rate this!"
ImageOff="~/images/EmptyStar.gif"
ImageOn="~/images/FilledStar.gif"
ImageOver="~/images/FilledStar.gif"
commandName='EditItem'
></cc:Rater>
</ItemTemplate>
<EditItemTemplate>
<cc:Rater
ID="Rater1"
runat="server"
Value='0'
MaxValue="5"
ToolTip="Rate this!"
ImageOff="~/images/EmptyStar.gif"
ImageOn="~/images/FilledStar.gif"
ImageOver="~/images/FilledStar.gif"
commandName='UpdateItem'
></cc:Rater>
</EditItemTemplate>
</asp:DataList>
modified on Monday, April 18, 2011 8:03 AM
|
|
|
|
 |
|
 |
Hi,
Actually, my control does not support CommandName property. I posted an update to make the control supports CommandName and can raise OnItemCommand well. Hope this help.
Note: you have to wait for the editor approves the update pack.
Tai
|
|
|
|
 |
|
 |
That's great! Thank you very much!
|
|
|
|
 |
|
 |
Hi,
I'm having a problem on the mouse over. It does not show the intended image specified in the ImageOver property.
Here is how my control looks like.
<cc:Rater ID="AspNetRater1" runat="server" ImageOff="Portals/_default/Skins/MinimalExtropy/rating/ratingStarEmpty.png"
Value="4" MaxValue="5" ImageOn="Portals/_default/Skins/MinimalExtropy/rating/ratingStarFilled.png"
ImageOver="Portals/_default/Skins/MinimalExtropy/rating/ratingStarFilled.png"
ToolTip="I'm a rater"></cc:Rater>
The ImageOn property shows the image fine.
Thanks for the help.
|
|
|
|
 |
|
 |
I tested on case: ImageOn == ImageOver. It works well on IE8, FF and Chrome. Which browser are you using?
|
|
|
|
 |
|
 |
Hi,
I'm using IE 8 and site is in DNN.
Thanks.
|
|
|
|
 |
|
 |
I cannot reproduce the bug on my machine. I guess that my JS script has a problem with your environment. Could you do some debugs? The script of hover event is generated in Rater.RenderHoverScript().
|
|
|
|
 |
|
 |
Thanks, issue sorted. I added "~" in the image properties.
|
|
|
|
 |
|
 |
how i get vote value in cs
lbllabel.Text ="Your Rate this : "+ Rater1.Value+ " Star";???
|
|
|
|
 |
|
 |
Yes, that's right
|
|
|
|
 |
|
 |
but
1、 when I clicked that,it still show the value that in aspx set value
code is :
<cc:Rater ID="Rater1" runat="server"
ImageOff="passive_star.gif"
Value="2" MaxValue="5" ImageOn="end_star.gif"
ToolTip="I'm a rater" OnCommand="Rater1_Command"
ImageOver="active_star.gif"></cc:Rater>
nbsp;<asp:Label ID="lbllabel" runat="server">
2、how to lock options after clicked ??/
thanx a lot!!!!
|
|
|
|
 |
|
 |
yeah, that's my fault. I fixed by adding "Value = ...":
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
{
Value = Convert.ToInt32(eventArgument);
OnCommand(new CommandEventArgs(this.UniqueID, Convert.ToInt32(eventArgument)));
}
To disable rater:
if (Enabled)
{
writer.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackClientHyperlink(this, i.ToString()));
writer.AddAttribute("onmouseover", "javascript:RatingHover(this)");
writer.AddAttribute("onmouseout", "javascript:RatingRefresh(this)");
}
I'll also update the rater to support image's URL "~/image/image_name.gif".
Thanks
|
|
|
|
 |
|
 |
I've got the trigger set up, and it works fine.
However, I also need to add some Javascript to my update panel which reinitialises a TinyMCE editor on postbacks. As soon as I add this in a script block...
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(<%=this.ClientID%>_InitializeRequestHandler);
function <%=this.ClientID%>_InitializeRequestHandler(sender, args) {
}
...it breaks the Rater. When I click on it, I'm getting:
Uncaught Sys.ArgumentNullException: Sys.ArgumentNullException: Value cannot be null.
Parameter name: postBackElement
Any ideas?
Mike
|
|
|
|
 |
|
 |
Hello Mike,
Sorry, I never faced this exception.
Have you tried to isolate the problem? the problem just show up when using the Rater?
If yes, I will take a look at the rater's JS.
Tai
|
|
|
|
 |
|
 |
Hi - yes, it's just when using the Rater.
I've had to work around it for now by using the AjaxControlToolkit "Rating" control rather than this, and that seems to work fine.
Thanks,
Mike
|
|
|
|
 |
|
 |
I can't reproduce your issue. Plz look into my code and let me know how I can reproduce.
<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="AJAXEnabledWebApplication1._Default" ValidateRequest="false" %>
<%@ Register Namespace="ASPnetRater" Assembly="ASPnetRater" TagPrefix="cc" %>
<!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>Untitled Page</title>
<!---->
<script type="text/javascript" src="/jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas"
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<textarea name="content" cols="50" rows="15">This is some content that will be editable with TinyMCE.</textarea>
<cc:Rater ID="Rater1" runat="server" ImageOff="/images/rating_grey_star.gif" Value="3"
MaxValue="5" ImageOn="/images/rating_red_star.gif" ToolTip="I'm a rater" OnCommand="Rater1_Command"
ImageOver="/images/rating_yellow_star.gif"></cc:Rater>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(<%=this.ClientID%>_InitializeRequestHandler);
function <%=this.ClientID%>_InitializeRequestHandler(sender, args) {
//do something
}
</script>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace AJAXEnabledWebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager1.RegisterAsyncPostBackControl(Rater1);
}
protected void Rater1_Command(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(string), "initMCE", "tinyMCE.init({mode : \"textareas\"});", true);
}
}
}
Thanks,
Tai
|
|
|
|
 |
|
 |
I am also experiencing a problem with the update panel, it seems to post back even when the control is inside the updatepanel. I am new to Ajax but very experienced in asp.net, am I missing something?
I have registered the asynpostbackcontrol, but still the page is refreshing upon new selection.
Ray
Rayman
|
|
|
|
 |
|
 |
Where is your RegisterAsyncPostBackControl() placed?
If you insert a button in the UpdatePanel and then click the button. It makes a normal post back or asyn post back?
Tai
|
|
|
|
 |
|
 |
Actually now it seems to work just fine (restarted the visual studio).
But I am experiencing a different problem, I have 3 rating controls together, and each time I make a selection on one of them, the selection from the other resets.
I have tried using update panel per each and one for all, with no success.
Do you have any advice?
Rayman
|
|
|
|
 |
|
 |
It's a bug. I don't save/load the value of the rater to ControlState. You can fix this bug right now by add objState[0] = _value; to protected override object SaveControlState()
and _value = (int)savedState[0]; to protected override void LoadControlState(object state)
Or wait until the next update of this article.
Thank for reporting this bug!
Tai
|
|
|
|
 |
|
 |
That's great, thank you for sharing this.
Mayby I have some improvement. When using ImageOn, ImageOff and ImageOver properties in the Rater control, you should call ResolveUrl(ImageOn) and so on. This ensures that you can set these properties using tilda notation ("~/assets/..."):
<cc:Rater ID="Rater1" runat="server"
ImageOff="~/assets/images/rating_grey_star.gif"
Value="3" MaxValue="5" ImageOn="~/assets/images/rating_red_star.gif"
ToolTip="I'm a rater" önCommand="Rater1_Command"
ImageOver="~/assets/images/rating_yellow_star.gif"></cc:Rater>
-ernest
|
|
|
|
 |
|
 |
Thank ernest_elias,
I'll update my source code right now.
Ops, Why I can't edit my article?
modified on Thursday, June 18, 2009 9:51 PM
|
|
|
|
 |