Click here to Skip to main content
15,894,540 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Calling Dll file From JavaScripts Pin
Not Active8-Feb-08 2:33
mentorNot Active8-Feb-08 2:33 
GeneralRe: Calling Dll file From JavaScripts Pin
Abhijit Jana8-Feb-08 21:43
professionalAbhijit Jana8-Feb-08 21:43 
QuestionPage Refresh, WHY??? Pin
zeeShan anSari8-Feb-08 2:15
zeeShan anSari8-Feb-08 2:15 
GeneralRe: Page Refresh, WHY??? Pin
Not Active8-Feb-08 2:36
mentorNot Active8-Feb-08 2:36 
AnswerRe: Page Refresh, WHY??? Pin
Vasudevan Deepak Kumar8-Feb-08 3:50
Vasudevan Deepak Kumar8-Feb-08 3:50 
AnswerRe: Page Refresh, WHY??? Pin
Guffa8-Feb-08 8:26
Guffa8-Feb-08 8:26 
GeneralAsp.Net 1.1 Threading... Thread is not calling the method Pin
thinkers8-Feb-08 1:55
thinkers8-Feb-08 1:55 
GeneralHelp in the 5 star rating control Pin
Neeraj Kr8-Feb-08 1:34
Neeraj Kr8-Feb-08 1:34 
Hi,

I have created a five star rating control. I have used ASP.Net 2.0 Clent Callbacks to implement the same. Following is my code


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="RatingControl.ascx.cs" Inherits="RatingControl" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler"%>

<script language="javascript" type="text/javascript">
var totChecked = "<%=totChecked%>";
function callSwapImage(strVal)
{
var countRec;
var imgName;
for (countRec = 1; countRec<=parseInt(strVal); countRec++)
{
imgName = "imgStar" + String(countRec);
document.images[imgName].src = "images/starGold.gif";
}
}

function callSwapRedo()
{
var message = "0";
var context = "";
CallServer(message, context);
}

function onImgClick(strVal)
{
var countRec;
var imgName;
var message = strVal;
var context = "";
CallServer(message, context);
}

function ShowSuccess(sMessage, Context)
{
for (countRec = 1; countRec<=parseInt(sMessage) + 1; countRec++)
{
imgName = "imgStar" + String(countRec);
document.images[imgName].src = "images/starGold.gif";
}
// for (countRec = parseInt(sMessage)+1; countRec<=5; countRec++)
// {
// imgName = "imgStar" + String(countRec);
// document.images[imgName].src = "images/starWhite.gif";
// }
}

</script>

<asp:Image ID="imgStar1" name="imgStar1" runat="server" onClick="onImgClick('1')" onMouseOver="callSwapImage('1')" onMouseOut="callSwapRedo()" AlternateText="1" ImageUrl="~/images/starWhite.gif"/>
<asp:Image ID="imgStar2" name="imgStar2" runat="server" onClick="onImgClick('2')" onMouseOver="callSwapImage('2')" onMouseOut="callSwapRedo()" AlternateText="2" ImageUrl="~/images/starWhite.gif"/>
<asp:Image ID="imgStar3" name="imgStar3" runat="server" onClick="onImgClick('3')" onMouseOver="callSwapImage('3')" onMouseOut="callSwapRedo()" AlternateText="3" ImageUrl="~/images/starWhite.gif"/>
<asp:Image ID="imgStar4" name="imgStar4" runat="server" onClick="onImgClick('4')" onMouseOver="callSwapImage('4')" onMouseOut="callSwapRedo()" AlternateText="4" ImageUrl="~/images/starWhite.gif"/>
<asp:Image ID="imgStar5" name="imgStar5" runat="server" onClick="onImgClick('5')" onMouseOver="callSwapImage('5')" onMouseOut="callSwapRedo()" AlternateText="5" ImageUrl="~/images/starWhite.gif"/>

---------------------------------------------------------------

Following is the code for code behind of the same

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;

public partial class RatingControl : System.Web.UI.UserControl
{
public string rateFor;
public int currentRating;
public string txtMsg;
public string sCallBackFunctionInvocation;
protected string returnValue;
protected string totChecked;

protected void Page_Load(object sender, EventArgs e)
{
sCallBackFunctionInvocation = Page.ClientScript.GetCallbackEventReference(this, "message", "ShowSuccess",
"context");
String callbackScript;
callbackScript = "function CallServer(message, context)" +
"{ " + sCallBackFunctionInvocation + ";}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"CallServer", callbackScript, true);

}

public void RaiseCallbackEvent(string eventArgument)
{
int countRec;
int remCount;
string imgButName;
//if (eventArgument == "0")
//{
// for (countRec = 1; countRec <= 5; countRec++)
// {
// imgButName = "imgStar" + countRec.ToString().Trim();
// ((Image)this.FindControl(imgButName)).ImageUrl = "images/starWhite.gif";
// }
// returnValue = eventArgument;
//}
//else
//{
// currentRating = Convert.ToInt16(eventArgument);
// remCount = 5 - currentRating;
// for (countRec = 1; countRec <= currentRating; countRec++)
// {
// imgButName = "imgStar" + countRec.ToString().Trim();
// ((Image)this.FindControl(imgButName)).ImageUrl = "images/starGold.gif";
// }
// returnValue = eventArgument;
//}
returnValue = eventArgument;

}

public string GetCallbackResult()
{
return returnValue;
}


}
------------------------------------------------------

The problem I am facing is that when I click on an image to rate, the OnMouseOut also activates and the images don't show rated.

Also, since I am a novice, I dont know how to pass value of rating on image clicking to the page that implements the control.

Please help

-----Have A Nice Day-----

GeneralRe: Help in the 5 star rating control Pin
rajanandal8-Feb-08 1:39
rajanandal8-Feb-08 1:39 
GeneralRe: Help in the 5 star rating control Pin
Neeraj Kr8-Feb-08 2:12
Neeraj Kr8-Feb-08 2:12 
Questionhow to add verious control selected data to gridview Pin
mohd imran abdul aziz8-Feb-08 0:52
mohd imran abdul aziz8-Feb-08 0:52 
AnswerRe: how to add verious control selected data to gridview Pin
Gandalf_TheWhite8-Feb-08 2:36
professionalGandalf_TheWhite8-Feb-08 2:36 
Questionwhat port does a web server connect to sql server Pin
eyeseetee7-Feb-08 23:56
eyeseetee7-Feb-08 23:56 
AnswerRe: what port does a web server connect to sql server Pin
ChrisKo8-Feb-08 9:24
ChrisKo8-Feb-08 9:24 
GeneralOnline Exam Application Pin
sjs4u7-Feb-08 23:30
sjs4u7-Feb-08 23:30 
GeneralRe: Online Exam Application Pin
Imran Khan Pathan7-Feb-08 23:47
Imran Khan Pathan7-Feb-08 23:47 
JokeRe: Online Exam Application Pin
SHatchard8-Feb-08 2:53
SHatchard8-Feb-08 2:53 
Generalwindow Close event Pin
sulabh20207-Feb-08 22:52
sulabh20207-Feb-08 22:52 
GeneralRe: window Close event Pin
Imran Khan Pathan7-Feb-08 23:20
Imran Khan Pathan7-Feb-08 23:20 
GeneralDetermining if a page is PostBack in JavaScript Pin
rajanandal7-Feb-08 22:33
rajanandal7-Feb-08 22:33 
GeneralRe: Determining if a page is PostBack in JavaScript Pin
Gandalf_TheWhite7-Feb-08 23:26
professionalGandalf_TheWhite7-Feb-08 23:26 
GeneralRe: Determining if a page is PostBack in JavaScript Pin
rajanandal7-Feb-08 23:45
rajanandal7-Feb-08 23:45 
GeneralRe: Determining if a page is PostBack in JavaScript Pin
Gandalf_TheWhite8-Feb-08 23:29
professionalGandalf_TheWhite8-Feb-08 23:29 
GeneralGetting ds data and binding to arraylist Pin
sjs4u7-Feb-08 22:01
sjs4u7-Feb-08 22:01 
Generalsql server to web server Pin
eyeseetee7-Feb-08 21:59
eyeseetee7-Feb-08 21:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.