I am working on aspx web page in which two updatepanels are placed. In inner Updatepanel there is timer trigger is enabled and in that timer tick event i want to make a panel visible on specific condition. But unfortunately, the Panel's visibility is not changed. My code is as follows:-
protected void ChatTextTimer_Tick(object sender, EventArgs e)
{
//if (!worker1.IsBusy)
//{
// worker1.RunWorkerAsync();
//}
if (lblHired.Text == "Hiring")
{
con.Open();
if (Label3.Text == "Approved")
{
UpdatePanel2.ChildrenAsTriggers = false;
lblHired.Text = "Hired";
Panel3.Visible = false;
}
}
My aspx code is as follows:-
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:TextBox ID="TxtBox1" runat="server" TextMode="MultiLine" ReadOnly="True" width="100%" Height="250px" AutoPostBack="False" style="margin-left:10px;resize:none;font-family:Times New Roman;font-size:14px;" MaintainScrollPositionOnPostBack="True" ></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SendButton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="ChatTextTimer" EventName="Tick" />
</Triggers>
</asp:UpdatePanel>
<asp:Panel ID="Panel3" Visible="false" runat="server" style="height: 160px; position: absolute; width: 339px; opacity: 1; background-color: rgb(255, 255, 126); border: 1px solid rgb(51, 51, 51); border-radius: 15px; padding: 46spx 16px 38px 14px; left: 20px;top:20px;">
<div>
<br />
<br />
<br />
<asp:Image ID="Image3" runat="server" ImageUrl="~/loading.gif" style="margin-left:151px;" />
<br />
<br />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Related
I'm using the latest ajax toolkit version. I've tried to put the rating control in a datalist, but the OnChanged event for some reason isn't firing.
That's the normal ASPX.NET page:
<asp:DataList ID="DataListEpisodes" runat="server" Style="position: relative; bottom: 330px;" Visible="False" RepeatColumns="1" OnItemDataBound="DataListEpisodes_ItemDataBound" DataKeyField="EpisodeID" OnItemCommand="DataListEpisodes_ItemCommand">
<ItemTemplate>
<table>
<tr>
<td>
<td>
<asp:Image ID="ImageEpisodeImage" class="EpisodeImage" runat="server" ImageUrl='<%# Eval("EpisodeImage", "https://image.tmdb.org/t/p/original{0}") %>' />
</td>
</td>
<td>
<asp:Label ID="LabelEpisodeNumber" runat="server" Style="font-family: Gotham Ultra; font-size: 25px; font-weight: bold;"
Text='<%# Eval("SeasonNumber", "Season {0}") + ", " + Eval ("EpisodeNumber", "Episode {0}") %>'></asp:Label>
<br />
<asp:Label ID="LabelEpisodeName" Style="font-family: Proxima Nova Semibold; font-size: 20px; font-weight: bold;" runat="server" Text='<%# Bind("EpisodeName") %>'></asp:Label>
<br />
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="True" class="LabelOverview" Text='<%# Bind("EpisodeOverview") %>' TextMode="MultiLine"></asp:TextBox>
<br />
<asp:Button ID="ButtonAddEpisode" class="ButtonAddEpisode" runat="server" Text="Add Episode To Watch History" CommandName="AddEpisode" />
<asp:Button ID="ButtonRemoveEpisode" class="ButtonAddEpisode" runat="server" Text="Remove Episode From Watch History" CommandName="RemoveEpisode" />
<br />
<asp:Button ID="ButtonWatchListAdd" class="ButtonEpisodeWatchList" runat="server" Text="Add Episode To Future Watch List" CommandName="AddWatchList" />
**<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<ajaxToolkit:Rating ID="Rating1" OnChanged="OnRatingChanged" style="position: relative;right: 301px;top: 16px;" AutoPostBack="true" runat="server"
StarCssClass="Star" EmptyStarCssClass="Star"
FilledStarCssClass="FilledStar" WaitingStarCssClass="Star">
</ajaxToolkit:Rating>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Rating1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>**
</tr>
</table>
<br />
<br />
<br />
<br />
</ItemTemplate>
</asp:DataList>
and that's the codebehind:
protected void OnRatingChanged(object sender, AjaxControlToolkit.RatingEventArgs e)
{
int rowIndex = ((sender as AjaxControlToolkit.Rating).NamingContainer as DataListItem).ItemIndex;
int RatingChosed = Rating1.CurrentRating;
int EpisodeID = Convert.ToInt32(DataListEpisodes.DataKeys[rowIndex].ToString());
}
Thank you if someone can help me :D
I am using 4 Modalpopupextender in my start-up page of my project. When I run my start-up page, the panels which I have set under PopupControlID in Modalpopupextender are visible even before the specified TargetControlID is clicked. I have tried to set visible of those to false but it dint helped me and I also tried to create a css class to hide a panel when page is loaded and to view the panel when specified button is clicked but it neither helped me. Please help. Thank you.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type = "text/css">
.hidePanel
{
display:none;
}
.showpanel
{
display : block;
}
.panel
{
background : gray;
padding : 10px;
}
div ul ul
{
display: none;
}
div ul li:hover > ul
{
display: block;
}
div ul li ul:hover > ul
{
display: block;
}
</style>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:modalpopupextender ID="Modalpopupextender1" CancelControlID = "Button8" TargetControlID = "Button2" PopupControlID = "StaffSP" runat="server"></asp:modalpopupextender>
<asp:modalpopupextender ID="Modalpopupextender2" CancelControlID = "Button10" TargetControlID = "Button3" PopupControlID = "StaffFP" runat="server"></asp:modalpopupextender>
<asp:modalpopupextender ID="Modalpopupextender3" CancelControlID = "Button12" TargetControlID = "Button5" PopupControlID = "AdminSP" runat="server"></asp:modalpopupextender>
<asp:modalpopupextender ID="Modalpopupextender4" CancelControlID = "Button14" TargetControlID = "Button6" PopupControlID = "AdminSP" runat="server"></asp:modalpopupextender>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="XX-Large" Text="Automated Examination System"></asp:Label><br /> <br /><br />
<asp:Panel ID = "Main" runat = "server" Height="181px" Width="275px">
<ul>
<li style="margin-removed 33px; width: 169px;"> <asp:LinkButton ID = "LinkAdmin" runat = "server" onclick="LinkAdmin_Click">Coordinator</asp:LinkButton></li>
<li style="width: 172px; margin-removed 33px"> <asp:LinkButton ID="LinkStaff" runat="server" onclick="LinkStaff_Click">Staff</asp:LinkButton></li>
<li style="margin-removed 33px"> <asp:LinkButton ID = "LinkStudent" runat = "server">Student</asp:LinkButton>
<ul>
<li><asp:LinkButton ID = "LinkButton1" runat = "server">Fresh Registration</asp:LinkButton></li>
<li><asp:LinkButton ID = "LinkButton2" runat = "server">Re Registration</asp:LinkButton></li>
</ul>
</li>
</ul>
</asp:Panel>
</div>
<asp:Panel ID="StaffLogin" runat="server" Height="59px"
style="z-index: 1; left: 302px; top: 112px; position: absolute; height: 59px; width: 275px"
Visible="False" Width="275px">
Staff<br />
<asp:Button ID="Button1" runat="server" Text="Login" />
<asp:Button ID="Button2" runat="server" Text="New Staff" />
<asp:Button ID="Button3" runat="server" Text="Fogot Password" />
</asp:Panel>
<asp:Panel ID="AdminLogin" runat="server"
style="z-index: 1; left: 302px; top: 193px; position: absolute; height: 78px; width: 275px"
Visible="False" Width="275px">
Admin<br />
<asp:Button ID="Button4" runat="server" Text="Login" />
<asp:Button ID="Button5" runat="server" Text="New Admin" />
<asp:Button ID="Button6" runat="server" Text="Forgot Password" />
</asp:Panel>
<asp:Panel ID="StaffSP" runat="server" Height="48px" Width="274px">
Staff SP<br />
<asp:Button ID="Button7" runat="server" Text="Button" />
<asp:Button ID="Button8" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="StaffFP" runat="server" Height="48px" Width="274px">
Staff FP<br />
<asp:Button ID="Button9" runat="server" Text="Button" />
<asp:Button ID="Button10" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminSP" runat="server" Height="48px" Width="274px">
Admin SP<br />
<asp:Button ID="Button11" runat="server" Text="Button" />
<asp:Button ID="Button12" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminFP" runat="server" Height="48px" Width="274px">
AdminFP<br />
<asp:Button ID="Button13" runat="server" Text="Button" />
<asp:Button ID="Button14" runat="server" Text="Cancel" />
</asp:Panel>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TrailPopup : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkAdmin_Click(object sender, EventArgs e)
{
AdminLogin.Visible = true;
StaffLogin.Visible = false;
}
protected void LinkStaff_Click(object sender, EventArgs e)
{
AdminLogin.Visible = false;
StaffLogin.Visible = true;
}
}
EDIT :
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<style type = "text/css">
.hidePanel
{
display:none;
}
.showpanel
{
display : block;
}
.panel
{
background : gray;
padding : 10px;
}
div ul ul
{
display: none;
}
div ul li:hover > ul
{
display: block;
}
div ul li ul:hover > ul
{
display: block;
}
</style>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="XX-Large" Text="Automated Examination System"></asp:Label><br /> <br /><br />
<asp:Panel ID = "Main" runat = "server" Height="181px" Width="275px">
<ul>
<li style="margin-left: 33px; width: 169px;"> <asp:LinkButton ID = "LinkAdmin" runat = "server" onclick="LinkAdmin_Click">Coordinator</asp:LinkButton></li>
<li style="width: 172px; margin-left: 33px"> <asp:LinkButton ID="LinkStaff" runat="server" onclick="LinkStaff_Click">Staff</asp:LinkButton></li>
<li style="margin-left: 33px"> <asp:LinkButton ID = "LinkStudent" runat = "server">Student</asp:LinkButton>
<ul>
<li><asp:LinkButton ID = "LinkButton1" runat = "server">Fresh Registration</asp:LinkButton></li>
<li><asp:LinkButton ID = "LinkButton2" runat = "server">Re Registration</asp:LinkButton></li>
</ul>
</li>
</ul>
</asp:Panel>
</div>
<asp:Panel ID="StaffLogin" runat="server" Height="59px"
style="z-index: 1; left: 302px; top: 112px; position: absolute; height: 59px; width: 275px"
Visible="False" Width="275px">
Staff<br />
<asp:Button ID="Button1" runat="server" Text="Login" />
<asp:Button ID="Button2" runat="server" Text="New Staff" />
<asp:Button ID="Button3" runat="server" Text="Fogot Password" />
</asp:Panel>
<asp:Panel ID="AdminLogin" runat="server" style="left: 302px; top: 193px; position: absolute; height: 78px; width: 275px" Visible="False" Width="275px">Admin<br />
<asp:Button ID="Button4" runat="server" Text="Login" />
<asp:Button ID="Button5" runat="server" Text="New Admin" />
<asp:Button ID="Button6" runat="server" Text="Forgot Password" />
</asp:Panel>
<asp:Panel ID="StaffSP" Visible = "false" runat="server" Height="48px" Width="274px">
Staff SP<br />
<asp:modalpopupextender ID="Modalpopupextender1" CancelControlID = "Button8" TargetControlID = "Button2" PopupControlID = "StaffSP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button7" runat="server" Text="Button" />
<asp:Button ID="Button8" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="StaffFP" Visible = "false" runat="server" Height="48px" Width="274px">
Staff FP<br />
<asp:modalpopupextender ID="Modalpopupextender2" CancelControlID = "Button10" TargetControlID = "Button3" PopupControlID = "StaffFP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button9" runat="server" Text="Button" />
<asp:Button ID="Button10" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminSP" Visible = "false" runat="server" Height="48px" Width="274px">
Admin SP<br />
<asp:modalpopupextender ID="Modalpopupextender4" CancelControlID = "Button14" TargetControlID = "Button6" PopupControlID = "AdminSP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button11" runat="server" Text="Button" />
<asp:Button ID="Button12" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminFP" Visible = "false" runat="server" Height="48px" Width="274px">
AdminFP<br />
<asp:modalpopupextender ID="Modalpopupextender3" CancelControlID = "Button12" TargetControlID = "Button5" PopupControlID = "AdminFP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button13" runat="server" Text="Button" />
<asp:Button ID="Button14" runat="server" Text="Cancel" />
</asp:Panel>
</form>
</body>
</html>
Call your css class hide panel in every PopupControl used for modalpopupextender control:
`<asp:Panel ID="StaffSP" runat="server" CssClass="hide" Height="48px" Width="274px" >
Staff SP<br />
<asp:Button ID="Button7" runat="server" Text="Button" />
<asp:Button ID="Button8" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="StaffFP" runat="server" Height="48px" Width="274px" style="display:none;">
Staff FP<br />
<asp:Button ID="Button9" runat="server" Text="Button" />
<asp:Button ID="Button10" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminSP" runat="server" Height="48px" Width="274px" CssClass="hidePanel">
Admin SP<br />
<asp:Button ID="Button11" runat="server" Text="Button" />
<asp:Button ID="Button12" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminFP" runat="server" Height="48px" Width="274px" Visible="false">
AdminFP<br />
<asp:Button ID="Button13" runat="server" Text="Button" />
<asp:Button ID="Button14" runat="server" Text="Cancel" />
</asp:Panel>`
you have put all the 4 TargetControlIDs inside the panels which are not visible
I have a delete button on a repeater which is in update panel. When i click the delete button, it can delete, but It takes about 10 seconds. So I want to add a loading gif . I am beginner on adding gif. Please help me. Thanks for interests
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:NET2ConnectionString %>' SelectCommand="SELECT * FROM [ProductsRA]"></asp:SqlDataSource>
<asp:Repeater ID="rptuser" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="rpr1_ItemCommand" OnItemDataBound="rpr1_ItemDataBound">
<ItemTemplate>
<tr>
<td class="GridItems">
<asp:ImageButton runat="server" ID="delbtn" ImageUrl="~/images/delete.gif" CommandName="Delete" CommandArgument='<%# Eval("ID") %>' ValidationGroup="ab" ToolTip="Delete User" /></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"ID") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"ProductName") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"Quantity") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"UnitPrice") %></td>
<td class="GridItems">
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="rptuser" />
</Triggers>
</asp:UpdatePanel>
this is cs:
protected void rpr1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
DataSet.ProductsRADataTable dt = new DataSet.ProductsRADataTable();
DataSetTableAdapters.ProductsRATableAdapter adp = new DataSetTableAdapters.ProductsRATableAdapter();
if (e.CommandName == "Delete")
{
adp.DeleteQuery(Convert.ToInt32(e.CommandArgument));
}
}
You can use UpdateProgess control for this.
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div class="loading_div">
<p>Please wait while we process the request.</p>
<img src="/Images/loader.gif" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
Use an overlay div if you want to block the page while processing the request.
.loading_div {
position: absolute;
color:#fff;
background-color: #000;
z-index: 2000 !important;
opacity: 0.6;
overflow: hidden;
text-align: center;
top: 0;
left: 0;
height: 100%;
width: 100%;
padding-top:20%;
}
It will render like this while the request is processed: http://jsfiddle.net/codeandcloud/jLmbmLmn/
Hi I have an asp updatePanel which contains several asp panels. The way it should function is you click the button in the first panel it hides that panel and shows the next. That works fine the problem comes with the next panel. If I try and use either of the button controls within that panel nothing happens.
Heres the html
<asp:UpdatePanel runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align:left; width:90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px;
margin-top: 10px" Width="100px" onclick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" onclick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px;
margin-top: 10px" Width="100px" ValidationGroup="rejCom"
onclick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
c# code
protected void btnReject_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = true;
pnlAppRej.Visible = false;
}
protected void btnBackRejCom_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
its the btnBackRejCom_Click method which doesnt seem to fire. But I have tested setting the pnlRejCom to visible and the method works fine.
Thanks in advance
Charlie
your problem seems to be different.
I would suggest, delete the
protected void btnBackRejCom_Click(object sender, EventArgs e){}
and again create a new event.
This is what i tried and is working fine now.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnReject" />
<asp:AsyncPostBackTrigger ControlID="btnBackRejCom" />
<asp:PostBackTrigger ControlID="btnDoneRejCom" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align: left; width: 90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" OnClick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnBackRejCom_Click1" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px; margin-top: 10px"
Width="100px" ValidationGroup="rejCom"
OnClick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
code behind :
protected void btnBackRejCom_Click1(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
Hope this helps. Happy Coding..!!!
I have same problem so I have just added CausesValidation="False" then it works fine for me.so please add CausesValidation in btnBackRejCom button like as below
Please try it
<asp:Button ID="btnBackRejCom" runat="server" CausesValidation="False" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
I think It works for you :)
I have this view in my asp.net application :
<asp:UpdatePanel ID="C_Compte" runat="server" UpdateMode="Conditional">
<ContentTemplate>
Métier:
<asp:TextBox ID="tbAddMetier" CssClass="Textboxes" Width="300px" Height="25px" runat="server"></asp:TextBox>
<asp:Button ID="btnAddMetier" runat="server" Text="Ajouter" CssClass="OffreEmploiSearch" OnClick="Button1_Click" />
<h4 style="font-weight: bold">Mes métiers</h4>
<asp:Repeater ID="rptrMetier" runat="server">
<ItemTemplate>
<div style="font: normal normal normal 14px/1.4em play, sans-serif; color: rgb(95, 94, 93); padding-left: 10px; line-height: 22px">
<strong><%# Eval("Lebelle") %></strong></a>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Design_Ressources/img/attachment.png" OnCommand="ImageButton1_Command" CommandArgument='<%# Eval("Lebelle") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
in the code behind
protected void ImageButton1_Command(object sender, CommandEventArgs e)
{
string newjob = e.CommandArgument.ToString().Split(',')[0];
}
Edit Data Binding
protected void Button1_Click(object sender, EventArgs e)
{
string newjob = tbAddMetier.Text;
Metier m = new Metier { Lebelle = newjob };
CurrentCandidat.Metier1.Add(m);
try
{
notrecontexte.SaveChanges();
}
catch
{
}
tbAddMetier.Text = "";
rptrMetier.DataSource = CurrentCandidat.Metier1;
rptrMetier.DataBind();
C_Compte.Update();
}
My problem is that the button clic event is never fired!!
What is the reason?
How can i fix my code?
Add Postback trigger for Button1 as mentioned below :
<asp:UpdatePanel ID="C_Compte" runat="server" UpdateMode="Conditional">
<ContentTemplate>
Métier:
<asp:TextBox ID="tbAddMetier" CssClass="Textboxes" Width="300px" Height="25px" runat="server"></asp:TextBox>
<asp:Button ID="btnAddMetier" runat="server" Text="Ajouter" CssClass="OffreEmploiSearch" OnClick="Button1_Click" />
<h4 style="font-weight: bold">Mes métiers</h4>
<asp:Repeater ID="rptrMetier" runat="server">
<ItemTemplate>
<div style="font: normal normal normal 14px/1.4em play, sans-serif; color: rgb(95, 94, 93); padding-left: 10px; line-height: 22px">
<strong><%# Eval("Lebelle") %></strong></a>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Design_Ressources/img/attachment.png" OnCommand="ImageButton1_Command" CommandArgument='<%# Eval("Lebelle") %>' />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnAddMetier"/>
</Triggers>
</asp:UpdatePanel>