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.
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!!!.
Related
I have a TextArea control in my content page which is inside an UpdatePanel:
<asp:UpdatePanel runat="server" ClientIDMode="Static" ID="upTaskDetailRight" UpdateMode="Conditional">
<ContentTemplate>
<div style="width: 98%; padding-bottom: 10px;" class="brClear">
<div style="width: 98%; height: 120px;">
<textarea id="taskNotes" runat="server" class="taskNotes" style="width: 100%; height: 100%; scrollbar-base-color: #A0A0A0; scrollbar-base-color: #A0A0A0; scrollbar-3dlight-color: #A0A0A0; scrollbar-highlight-color: #A0A0A0; scrollbar-track-color: #EBEBEB; scrollbar-arrow-color: #FFFFFF; scrollbar-shadow-color: #A0A0A0; scrollbar-darkshadow-color: #A0A0A0;"></textarea>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
I have a button in my MasterPage which is accessing the TextArea value from the content page and updating the SQL Database:
<asp:Panel ID="Panel93" runat="server" CssClass="navInnerDivContentsTopSubTwo">
<asp:ImageButton ID="ibSave" ImageUrl="~/theImages/Save.png" runat="server" CssClass="navImages" OnClick="btnSave_Click" />
<br />
<asp:LinkButton ID="btnSave" runat="server" Text="Save" ClientIDMode="Static" OnClick="btnSave_Click" CssClass="linkOff" />
</asp:Panel>
Code-behind:
System.Web.UI.HtmlControls.HtmlTextArea lblTDNotes;
lblTDNotes = (System.Web.UI.HtmlControls.HtmlTextArea)ContentMain.FindControl("taskNotes");
protected void btnSave_Click(object sender, EventArgs e)
{
string strSaveQuery = #"UPDATE HSI.RMMEMO SET MEMO = '" + lblTDNotes.Value + "' WHERE MEMOID = '" + hfMemoIDYT.Value + "'";
//MessageBox.Show(strSaveQuery);
using (SqlConnection scConn = new SqlConnection(strMainConn))
{
try
{
scConn.Open();
SqlCommand cmd = new SqlCommand(strSaveQuery, scConn);
cmd.ExecuteNonQuery();
Response.Redirect("YourTasks.aspx");
}
catch (Exception ce)
{
}
}
}
When the page loads, the TextArea has some pre populated data. If I make any changes to the TextArea data (add or remove text) and hit the SAVE button in the Master page, the lblTDNoted.Value from the strSaveQuery is using the pre populated data and not the updated entry.
How do I get the updated entry from the textarea?
Add <triggers> to your UpdatePanel.
<asp:UpdatePanel runat="server" ...>
<ContentTemplate>
...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
I have a repeater which i am trying to load after the page has loaded and have stumbled across the PreRender event. I have everything set up but the content of the repeater is not showing - the weird thing is that when i inspect the html, the code is there, just not displaying in the browser.
<asp:updatepanel id="panel1" runat="server" updatemode="Conditional" onprerender="upUpdatePanel_PreRender">
<contenttemplate>
<asp:repeater runat="server" id="mainContentRptr" onitemdatabound="bindDepts">
<headertemplate>
<div id="products-tabs-content" class="row tab-content">
</headertemplate>
<itemtemplate>
<div class="tab-pane" id='<%# eval("dept_id") %>
'> <asp:repeater runat="server" id="prodRepeater" onitemcommand="itemToCart">
<headertemplate>
.... </headertemplate>
<itemtemplate>
.... <asp:repeater runat="server" id="condRptr">
<headertemplate>
.... </headertemplate>
<itemtemplate>
.... </itemtemplate>
<footertemplate></footertemplate>
</asp:repeater>
</itemtemplate>
<footertemplate>
</div>
</footertemplate>
</asp:repeater>
</div>
<!-- End .tab-pane -->
</itemtemplate>
<footertemplate>
</footertemplate>
</asp:repeater>
</contenttemplate>
</asp:updatepanel>
As you can see a few nested repeaters... i also have my UpdateProgress control
<asp:UpdateProgress id="updateProgress" runat="server" AssociatedUpdatePanelID="panel1">
<ProgressTemplate>
<div style="position: relative; text-align: center; height: 100%; width: 100%; background-color: white; opacity: 0.7;margin:0 auto">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="images/loader.GIF" AlternateText="Loading ..." ToolTip="Loading ..." style="padding: 10px; position: relative; top: 45%;margin: 0 auto" />
<br/>
<span style="font-size: 16pt;font-weight: bold">Bulding your menu</span>
<br/>
<span>Please wait</span>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
and then the following to trigger the delayed load
<script language="javascript" type="text/javascript">
function pageLoad(sender, e) {
if (!e.get_isPartialLoad()) {
__doPostBack('<%= panel1.ClientID %>', 'aaaa');
}
}
</script>
and server side...
protected void upUpdatePanel_PreRender(object sender, EventArgs e)
{
if (Request["__EVENTTARGET"] == panel1.ClientID &&
Request.Form["__EVENTARGUMENT"] == "aaaa")
{
populateRepeaters(); //This has databind for each repeater
}
}
This works without the prerender but loading speeding will vary depending on data etc so i wanted to have it load after the page loaded.
Any help would be appreciated guys! :)
a repeater was sitting out of the updatepanel that controlled the visibility of everything above. it was populated in the prerender event but did not display. Ive moved it inside the panel and everyhting is now working
I have planed to implement two pops in asp.net page. The First popup perform when the page button Click, and the Second popup perform when the first popup button click.
But When I Implement this in code, i got fist popup only. Can't got the second popup open.
ASPX Code-
<head id="Head1" runat="server">
<title></title>
<style type="text/css">
.Background
{
background-color: Black;
filter: alpha(opacity=90);
opacity: 0.8;
}
.Popup
{
background-color: #FFFFFF;
border-width: 3px;
border-style: solid;
border-color: black;
padding-top: 10px;
padding-left: 10px;
width: 400px;
height: 350px;
}
.lbl
{
font-size: 16px;
font-style: italic;
font-weight: bold;
}
</style>
<script type="text/javascript">
function ShowModalPopup() {
$find("mp1").show();
return false;
}
function HideModalPopup() {
// alert("Yes");
$find("mp1").hide();
return false;
}
function ShowModalPopup1() {
$find("ModalPopupExtender1").show();
return false;
}
function HideModalPopup1() {
// alert("Yes");
$find("ModalPopupExtender1").hide();
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Button ID="btnPopup1" runat="server" Text="Fill Form in Popup" />
<!-- ModalPopupExtender -->
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="btnPopup1"
BehaviorID="modalPopupBehavior" CancelControlID="btnHide" BackgroundCssClass="Background">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panl1" runat="server" CssClass="Popup" align="center" Style="display: none">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txt" runat="server" />
<asp:Label ID="Label2" Text="RED" runat="server" ForeColor="red" />
<asp:Button ID="Button2" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
<asp:CheckBox ID="CheckBox1" TextAlign="Left" Text="ssdd" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnPopup1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="btnHide" runat="server" Text="Hide Modal Popup" OnClientClick="return HideModalPopup()" />
<!-- ModalPopupExtender 2 -->
<asp:Button ID="btnPopup2" runat="server" Text="Fill Form in Popup" />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1"
TargetControlID="btnPopup2" BehaviorID="modalPopupBehavior" CancelControlID="btnHide1"
BackgroundCssClass="Background">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" CssClass="Popup" align="center" Style="display: none">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" />
<asp:Label ID="Label1" Text="Blue" runat="server" ForeColor="Blue" />
<asp:Button ID="Button4" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
<asp:CheckBox ID="CheckBox2" TextAlign="Left" Text="ssdd" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnPopup2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="btnHide1" runat="server" Text="Hide Modal Popup" OnClientClick="return HideModalPopup1()" />
</asp:Panel>
<!-- ModalPopupExtender 2 -->
</asp:Panel>
<!-- ModalPopupExtender -->
</form>
</body>
C# Code -
protected void btnSubmit_Click(object sender, EventArgs e)
{
Label2.Text = "Blue";
}
protected void btnClose_Click(object sender, EventArgs e)
{
}
This link might be of good use to you.
http://aspdotnetcodebook.blogspot.com.au/2009/03/how-to-open-modalpopup-inside.html
Also to have a modal pop up over another modal popup you need to set the z-index otherwise there are chances that the 2nd popup might hide behind the 1st. The following are the links which explains the same.
How to show a modal pop up above other modal pop up
http://blogs.msdn.com/b/codejunkie/archive/2009/06/23/multiple-modal-popups-and-z-index.aspx
http://tiredblogger.wordpress.com/2008/07/24/layering-modal-popups-using-css-z-index/
http://forums.asp.net/p/1280547/2458840.aspx#2458840
Hope this helps.
Please take a look on below url.
http://www.codeproject.com/Articles/546817/ASP-NET-Popup-Control-Displaying-as-multiple-neste
Here is my screen:
Here is my code for the ItemTemplate in the Repeater:
<ItemTemplate>
<div style="float: left; overflow: hidden; display: inline-block; border-style: solid; margin: 5px; background-color: Silver">
<div style="text-align:center">
<asp:Label ID="lblImage" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "image") %>'></asp:Label>
</div>
<asp:Image runat="server" ID="image1" Width="250px" Height="250px" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "url") %>' />
<div style="text-align: center;">
<asp:Button runat="server" ID="btnNew" Text="New" />
<asp:Button runat="server" ID="btnOriginal" Text="Original" />
</div>
</div>
The Repeater uses a dataset in my program to populate the ItemTemplate's label and image controls. There's another field in my dataset called graphicID. I'd like to, somehow, pass the value in that field to the 'Original' button, so that if a user presses that button, that particular graphicID is passed into the click event. Does this make sense?
For instance, the second image is Captain Harlock. The graphicID for this image is 93. If the user presses the Original button under Captain Harlock, I want to pass 93 to the onClick event. I'm not sure how to do this, though. If someone could point me in the right direction, I'd greatly appreciate it!
<div style="text-align: center;">
<asp:Button runat="server" ID="btnNew" Text="New" />
<asp:Button runat="server" CommandName="cmd_original" CommandArgument="name of field which you want to access" ID="btnOriginal" Text="Original" />
</div>
EDIT
In repeater control
you have to add an event as below:
onitemcommand="Repeater1_ItemCommand"
In code behind
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "cmd_original")
{
Int32 id = Convert.ToInt32(e.CommandArgument);
}
}
I am working in C#.Net and Ajax Concepts. I am having 2 ModelPopup Extender in a page. I am also having 2 Buttons in that page. When i click the 1st Button 1 MP should be displayed and when i click the 2nd Button, 2nd MP should get displayed. This works fine for me for the first time. [i.e] When i click the 1st Button, 1st MP is displayed and When i click the 2nd Button, 2nd MP is displayed and once again if i click the 1st Button nothing happens.
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<ajaxToolKit:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panel1" TargetControlID="Button2">
</ajaxToolKit:ModalPopupExtender>
<asp:Button ID="Button2" ToolTip="Location" runat="server" Text="Location(+)"
OnClientClick="LocClick();" />
<asp:Panel ID="Panel1" runat="server" Style="display: block; width: 600px; overflow: scroll;
height: 440px;" BackColor="White">
<table>
<tr valign="top">
<td width="650">
<ct:ASTreeView ID="astvMyTree" runat="server" BasePath="~/Scripts/astreeview/" DataTableRootNodeValue="0"
BackColor="White" EnableRoot="false" EnableNodeSelection="true" EnableCheckbox="false"
EnableDragDrop="false" EnableTreeLines="true" EnableNodeIcon="false" EnableCustomizedNodeIcon="false"
EnableDebugMode="false" EnableContextMenuAdd="false" EnableParentNodeExpand="false"
EnableAjaxOnEditDelete="false" AutoPostBack="true" OnOnSelectedNodeChanged="astvMyTree_OnSelectedNodeChanged" />
</td>
<td>
<div id="divConsole" runat="server">
</div>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel5" runat="server">
<ContentTemplate>
<ajaxToolKit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel2"
TargetControlID="Button1">
</ajaxToolKit:ModalPopupExtender>
<asp:Button ID="Button1" ToolTip="Product" runat="server" Text="Product(+)"
OnClientClick="ProdClick();" />
<asp:Panel ID="Panel2" runat="server" Style="display: block; width: 600px; overflow: scroll;
height: 440px;" BackColor="White">
<table>
<tr valign="top">
<td width="650">
<ct:ASTreeView ID="ASTreeView1" runat="server" BasePath="~/Scripts/astreeview/" DataTableRootNodeValue="0"
BackColor="White" EnableRoot="false" EnableNodeSelection="true" EnableCheckbox="false"
EnableDragDrop="false" EnableTreeLines="true" EnableNodeIcon="false" EnableCustomizedNodeIcon="false"
EnableDebugMode="false" EnableContextMenuAdd="false" EnableParentNodeExpand="false"
EnableAjaxOnEditDelete="false" AutoPostBack="true" OnOnSelectedNodeChanged="astvMyTree_OnSelectedNodeChanged" />
</td>
<td>
<div id="div4" runat="server">
</div>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
I am just changing the back color of buttons in LocClick as well as ProdClick.
<script type="text/javascript">
function LocClick() {
var location = document.getElementById("<%= Button2.ClientID %>");
location.style.background = '#72BD66';
var product = document.getElementById("<%= Button1.ClientID %>");
product.style.background = '#065581';
var lastYear = document.getElementById('<%=chkLastYear.ClientID%>');
lastYear.checked = false;
}
How to fix this...