Retrieve Ajax star rating value to Asp.net backend
This is my rating control in aspx page. When user click the star, i want to update the label3.
<style type="text/css">
.Star {
background-image: url(img/Star.gif);
height: 17px;
width: 17px;
}
.WaitingStar {
background-image: url(img/WaitingStar.gif);
height: 17px;
width: 17px;
}
.FilledStar {
background-image: url(img/FilledStar.gif);
height: 17px;
width: 17px;
}
</style>
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" OnChanged="OnRatingChanged" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star" CurrentRating="2"
FilledStarCssClass="FilledStar">
</ajaxToolkit:Rating>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</div>
I tried out using Rating1.CurrentRating.ToString() but there is nothing on Label3.
protected void OnRatingChanged(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
Is my code wrong or I can get the value in another way? I'm planning to get the value from backend because later I will add it into my database. Please help. Thank you.
c# asp.net ajaxcontroltoolkit
add a comment |
This is my rating control in aspx page. When user click the star, i want to update the label3.
<style type="text/css">
.Star {
background-image: url(img/Star.gif);
height: 17px;
width: 17px;
}
.WaitingStar {
background-image: url(img/WaitingStar.gif);
height: 17px;
width: 17px;
}
.FilledStar {
background-image: url(img/FilledStar.gif);
height: 17px;
width: 17px;
}
</style>
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" OnChanged="OnRatingChanged" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star" CurrentRating="2"
FilledStarCssClass="FilledStar">
</ajaxToolkit:Rating>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</div>
I tried out using Rating1.CurrentRating.ToString() but there is nothing on Label3.
protected void OnRatingChanged(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
Is my code wrong or I can get the value in another way? I'm planning to get the value from backend because later I will add it into my database. Please help. Thank you.
c# asp.net ajaxcontroltoolkit
Please refer this link aspsnippets.com/Articles/…
– A.M. Patel
Jan 1 at 7:22
Could you try using e.Value or e.Tag, my friend?
– Tomato32
Jan 1 at 7:27
I think he mentioned thatOnChange()
don't get fired.
– Aria
Jan 1 at 8:13
add a comment |
This is my rating control in aspx page. When user click the star, i want to update the label3.
<style type="text/css">
.Star {
background-image: url(img/Star.gif);
height: 17px;
width: 17px;
}
.WaitingStar {
background-image: url(img/WaitingStar.gif);
height: 17px;
width: 17px;
}
.FilledStar {
background-image: url(img/FilledStar.gif);
height: 17px;
width: 17px;
}
</style>
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" OnChanged="OnRatingChanged" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star" CurrentRating="2"
FilledStarCssClass="FilledStar">
</ajaxToolkit:Rating>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</div>
I tried out using Rating1.CurrentRating.ToString() but there is nothing on Label3.
protected void OnRatingChanged(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
Is my code wrong or I can get the value in another way? I'm planning to get the value from backend because later I will add it into my database. Please help. Thank you.
c# asp.net ajaxcontroltoolkit
This is my rating control in aspx page. When user click the star, i want to update the label3.
<style type="text/css">
.Star {
background-image: url(img/Star.gif);
height: 17px;
width: 17px;
}
.WaitingStar {
background-image: url(img/WaitingStar.gif);
height: 17px;
width: 17px;
}
.FilledStar {
background-image: url(img/FilledStar.gif);
height: 17px;
width: 17px;
}
</style>
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" OnChanged="OnRatingChanged" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star" CurrentRating="2"
FilledStarCssClass="FilledStar">
</ajaxToolkit:Rating>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</div>
I tried out using Rating1.CurrentRating.ToString() but there is nothing on Label3.
protected void OnRatingChanged(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
Is my code wrong or I can get the value in another way? I'm planning to get the value from backend because later I will add it into my database. Please help. Thank you.
c# asp.net ajaxcontroltoolkit
c# asp.net ajaxcontroltoolkit
asked Jan 1 at 6:52
kitty_katkitty_kat
33
33
Please refer this link aspsnippets.com/Articles/…
– A.M. Patel
Jan 1 at 7:22
Could you try using e.Value or e.Tag, my friend?
– Tomato32
Jan 1 at 7:27
I think he mentioned thatOnChange()
don't get fired.
– Aria
Jan 1 at 8:13
add a comment |
Please refer this link aspsnippets.com/Articles/…
– A.M. Patel
Jan 1 at 7:22
Could you try using e.Value or e.Tag, my friend?
– Tomato32
Jan 1 at 7:27
I think he mentioned thatOnChange()
don't get fired.
– Aria
Jan 1 at 8:13
Please refer this link aspsnippets.com/Articles/…
– A.M. Patel
Jan 1 at 7:22
Please refer this link aspsnippets.com/Articles/…
– A.M. Patel
Jan 1 at 7:22
Could you try using e.Value or e.Tag, my friend?
– Tomato32
Jan 1 at 7:27
Could you try using e.Value or e.Tag, my friend?
– Tomato32
Jan 1 at 7:27
I think he mentioned that
OnChange()
don't get fired.– Aria
Jan 1 at 8:13
I think he mentioned that
OnChange()
don't get fired.– Aria
Jan 1 at 8:13
add a comment |
1 Answer
1
active
oldest
votes
I think what are you looking for is OnClick()
not OnChange()
, as when user click on Rate
control and change it's rating value you want to get current value of Rate
control and show it in a label, BTW you should do following below desc,
before doing anything think about the properties of UpdatePanel
like UpdateMode
and ChildrenAsTriggers
that you can set them like UpdateMode="Always" ChildrenAsTriggers="true"
for UpdatePanel1
if by setting them it still doesnt work do the below steps:
1- Firstly move that label controls into the ContentTemplate
of UpdatePanel
2- Then handle Click()
event of ajaxToolkit:Rating
3- At the end you must have something like in design mode:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar" OnChanged="OnRatingChanged" OnClick="Rating1_Click">
</ajaxToolkit:Rating>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
and the code behind for Rating1_Click
:
protected void Rating1_Click(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
this works like a charm!!!.
Omg yes. It works. Thank you so much.
– kitty_kat
Jan 1 at 8:27
You are most welcome.
– Aria
Jan 1 at 8:36
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993572%2fretrieve-ajax-star-rating-value-to-asp-net-backend%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think what are you looking for is OnClick()
not OnChange()
, as when user click on Rate
control and change it's rating value you want to get current value of Rate
control and show it in a label, BTW you should do following below desc,
before doing anything think about the properties of UpdatePanel
like UpdateMode
and ChildrenAsTriggers
that you can set them like UpdateMode="Always" ChildrenAsTriggers="true"
for UpdatePanel1
if by setting them it still doesnt work do the below steps:
1- Firstly move that label controls into the ContentTemplate
of UpdatePanel
2- Then handle Click()
event of ajaxToolkit:Rating
3- At the end you must have something like in design mode:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar" OnChanged="OnRatingChanged" OnClick="Rating1_Click">
</ajaxToolkit:Rating>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
and the code behind for Rating1_Click
:
protected void Rating1_Click(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
this works like a charm!!!.
Omg yes. It works. Thank you so much.
– kitty_kat
Jan 1 at 8:27
You are most welcome.
– Aria
Jan 1 at 8:36
add a comment |
I think what are you looking for is OnClick()
not OnChange()
, as when user click on Rate
control and change it's rating value you want to get current value of Rate
control and show it in a label, BTW you should do following below desc,
before doing anything think about the properties of UpdatePanel
like UpdateMode
and ChildrenAsTriggers
that you can set them like UpdateMode="Always" ChildrenAsTriggers="true"
for UpdatePanel1
if by setting them it still doesnt work do the below steps:
1- Firstly move that label controls into the ContentTemplate
of UpdatePanel
2- Then handle Click()
event of ajaxToolkit:Rating
3- At the end you must have something like in design mode:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar" OnChanged="OnRatingChanged" OnClick="Rating1_Click">
</ajaxToolkit:Rating>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
and the code behind for Rating1_Click
:
protected void Rating1_Click(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
this works like a charm!!!.
Omg yes. It works. Thank you so much.
– kitty_kat
Jan 1 at 8:27
You are most welcome.
– Aria
Jan 1 at 8:36
add a comment |
I think what are you looking for is OnClick()
not OnChange()
, as when user click on Rate
control and change it's rating value you want to get current value of Rate
control and show it in a label, BTW you should do following below desc,
before doing anything think about the properties of UpdatePanel
like UpdateMode
and ChildrenAsTriggers
that you can set them like UpdateMode="Always" ChildrenAsTriggers="true"
for UpdatePanel1
if by setting them it still doesnt work do the below steps:
1- Firstly move that label controls into the ContentTemplate
of UpdatePanel
2- Then handle Click()
event of ajaxToolkit:Rating
3- At the end you must have something like in design mode:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar" OnChanged="OnRatingChanged" OnClick="Rating1_Click">
</ajaxToolkit:Rating>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
and the code behind for Rating1_Click
:
protected void Rating1_Click(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
this works like a charm!!!.
I think what are you looking for is OnClick()
not OnChange()
, as when user click on Rate
control and change it's rating value you want to get current value of Rate
control and show it in a label, BTW you should do following below desc,
before doing anything think about the properties of UpdatePanel
like UpdateMode
and ChildrenAsTriggers
that you can set them like UpdateMode="Always" ChildrenAsTriggers="true"
for UpdatePanel1
if by setting them it still doesnt work do the below steps:
1- Firstly move that label controls into the ContentTemplate
of UpdatePanel
2- Then handle Click()
event of ajaxToolkit:Rating
3- At the end you must have something like in design mode:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" AutoPostBack="true" runat="server"
StarCssClass="Star" WaitingStarCssClass="WaitingStar" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar" OnChanged="OnRatingChanged" OnClick="Rating1_Click">
</ajaxToolkit:Rating>
<asp:Label runat="server" ID="label3"></asp:Label>
<asp:Label runat="server" ID="label4" Text="above"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
and the code behind for Rating1_Click
:
protected void Rating1_Click(object sender, RatingEventArgs e)
{
label3.Text = Rating1.CurrentRating.ToString();
}
this works like a charm!!!.
edited Jan 1 at 8:35
answered Jan 1 at 8:21
AriaAria
2,7031832
2,7031832
Omg yes. It works. Thank you so much.
– kitty_kat
Jan 1 at 8:27
You are most welcome.
– Aria
Jan 1 at 8:36
add a comment |
Omg yes. It works. Thank you so much.
– kitty_kat
Jan 1 at 8:27
You are most welcome.
– Aria
Jan 1 at 8:36
Omg yes. It works. Thank you so much.
– kitty_kat
Jan 1 at 8:27
Omg yes. It works. Thank you so much.
– kitty_kat
Jan 1 at 8:27
You are most welcome.
– Aria
Jan 1 at 8:36
You are most welcome.
– Aria
Jan 1 at 8:36
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53993572%2fretrieve-ajax-star-rating-value-to-asp-net-backend%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Please refer this link aspsnippets.com/Articles/…
– A.M. Patel
Jan 1 at 7:22
Could you try using e.Value or e.Tag, my friend?
– Tomato32
Jan 1 at 7:27
I think he mentioned that
OnChange()
don't get fired.– Aria
Jan 1 at 8:13