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>
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 have a gridview with dynamic controls. Resource name is something that I am picking up from Active directory. Search filter works in a way where you have to enter lastname, firstname and onlclick of lookup it will search. If there are more than one record a modalpopup will be displayed with dropdownlist with options to select from.
The issue is that I am unable to get the dropdown values populated into textbox present in gridview. I need this dropdown value in correct selected row's textbox.
Code behind:
protected void gvProjectResource_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Lookup")
{
GridViewRow clickedRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow;
TextBox t2 = ((TextBox)clickedRow.FindControl("t2"));
DataTable dt = globalObj.FindPersons(t2.Text.Split(',')[0].Trim(), t2.Text.Split(',')[1].Trim());
if (dt.Rows.Count > 1)
{
mpFindPerson.Show();
ddlPersons.Items.Clear();
ddlPersons.Items.Add(new ListItem { Value = "0", Text = "-Select User-" });
ddlPersons.DataSource = dt;
dt.Columns.Add("FullName", typeof(string), "DisplayName + ' | ' + MSID");
ddlPersons.DataTextField = "FullName";
ddlPersons.DataValueField = "MSID";
ddlPersons.DataBind();
}
else
{
t2.Text = dt.Rows[0].ItemArray[0].ToString();
}
}
if (e.CommandName == "Del")
{
}
}
protected void btnSelectPerson_Click(object sender, EventArgs e)
{
TextBox t2 = (gvProjectResource.SelectedRow.FindControl("t2") as TextBox);
t2.Text = ddlPersons.SelectedItem.Text;
mpFindPerson.Hide();
}
ASPX Code:
<div id="four">
<fieldset style="border: solid; border-width: thin; height: 220px; border-color: #a8a8a8;">
<legend id="Legend11" runat="server" visible="true" style="width: auto; margin-bottom: 0px; font-size: 12px; font-weight: bold; color: #1f497d;"> Project Resources </legend>
<div style="height: 210px; overflow: auto;">
<asp:GridView ID="gvProjectResource" Width="88%" HeaderStyle-Font-Size="X-Small" CssClass="labels" runat="server"
ShowFooter="true" AutoGenerateColumns="false" Style="margin-right: auto; margin-left:7px;"
OnRowDataBound="gvProjectResource_RowDataBound"
OnRowCommand="gvProjectResource_RowCommand" >
<Columns>
<asp:TemplateField HeaderText="Role" ItemStyle-VerticalAlign="Top" FooterStyle-VerticalAlign="Top" ItemStyle-Width="50%">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%# Eval("role") %>' Visible="false" />
<asp:DropDownList ID="ddlRole" Height="23px" Width="98%" runat="server" CssClass="DropDownListStyleOverview"></asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddlRole2" Height="23px" Width="98%" runat="server" CssClass="DropDownListStyleOverview"></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Resource Name" ItemStyle-VerticalAlign="Top" FooterStyle-VerticalAlign="Top" ItemStyle-Width="50%">
<ItemTemplate>
<asp:TextBox ID="t1" Height="23px" Width="98%" runat="server" ></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="t2" Height="23px" Width="68%" runat="server"></asp:TextBox>
<asp:LinkButton runat="server" Text="Lookup" CommandName="Lookup" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-VerticalAlign="Top" ItemStyle-Width="5%">
<ItemTemplate>
<asp:LinkButton runat="server" Text="Delete" CommandName="Del" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<div style="text-align: right;">
<asp:LinkButton runat="server" Text="Add New" ID="LinkButton2" CssClass="labels"></asp:LinkButton>
</div>
</div>
<asp:Button runat="server" ID="btnModalPopUpSearch" Style="display: none" />
<AjaxToolkit:ModalPopupExtender ID="mpFindPerson"
BehaviorID="mpFindPersonBehav"
runat="server"
DropShadow="true"
BackgroundCssClass="modalBackground"
PopupControlID="pnlFindPerson"
TargetControlID="btnModalPopUpSearch">
</AjaxToolkit:ModalPopupExtender>
<asp:Panel runat="Server" ID="pnlFindPerson" CssClass="modalPopup" style="position:relative;">
<div class="labels" runat="server" style="text-align:center; position:absolute; top:20%; height:10em; margin-top:auto; margin-left:20px;">
<asp:DropDownList ID="ddlPersons" runat="server" AppendDataBoundItems="true" Width="200px">
<asp:ListItem Text="-Select User-" Value="0" />
</asp:DropDownList>
<br />
<br />
<br />
<div style="text-align: center;">
<asp:Button runat="server" Font-Size="9pt" Text="Select" CssClass="buttons___" Style="float: left;"
ID="btnSelectPerson" OnClick="btnSelectPerson_Click" />
</div>
</div>
</asp:Panel>
</fieldset>
</div>
ok, so, there was nothing much to do.
have to add this.
protected void btnSelectPerson_Click(object sender, EventArgs e)
{
TextBox t2 = (TextBox)gvProjectResource.FooterRow.FindControl("t2");
t2.Text = ddlPersons.SelectedItem.Text;
mpFindPerson.Hide();
}
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>
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 a search button in my page. When I click the button, a paged datalist will show up
with result. I want to use modalPopupExtender with Datalist and collection pager. Is it possible ? Here is the code i tried but it doesn't work :
<asp:Label ID="Label5" runat="server"></asp:Label>
<asp:ModalPopupExtender ID="Label1_ModalPopupExtender" runat="server" CancelControlID="btThoat"
DynamicServicePath="" Enabled="True" PopupControlID="Panel1" TargetControlID="Label5">
</asp:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server">
<div style="margin-left: 20px; padding-top: 50px">
<asp:Label ID="lbl_CS" runat="server" Text="Ca sĩ" ForeColor="#FF33CC" Font-Size="18"
Visible="True"></asp:Label>
<asp:DataList ID="DataList1" runat="server" BackColor="White" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px" CellPadding="4" GridLines="Both" RepeatColumns="4"
OnItemDataBound="DataList1_ItemDataBound">
<FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
<ItemStyle BackColor="White" ForeColor="#330099" />
<ItemTemplate>
<table>
<tr>
<td style="width: 10px">
<asp:RadioButton ID="rd_CS" runat="server" GroupName="Casi" Text='<%# Eval("MaCS")%>'
AutoPostBack="False"></asp:RadioButton>
</td>
<td style="width: 75px">
<asp:Image ID="Img_Casi" runat="server" ImageUrl='<%#Eval("Hinhanh")%>' Width="75px"
Height="75px" BorderColor="#66FF33" />
</td>
<td style="width: 50px">
<asp:Label ID="lbl_Ten" runat="server" Text='<%#Eval("TenCS")%>'></asp:Label>
</td>
<td style="width: 40px">
<asp:Label ID="lbl_Ngaysinh" runat="server" Text='<%#Eval("Ngaysinh")%>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
</asp:DataList>
<cc2:CollectionPager ID="CollectionPager1" runat="server" MaxPages="1000" PagingMode="QueryString"
BackNextDisplay="Buttons" QueryStringKey="Datalist1">
</cc2:CollectionPager>
</div>
</asp:Panel>
Code in c#:
bool Checkcs()
{
string cs = "select MaCS, Quocgia, TenCS, Hinhanh, Thongtin, cast(convert(char(11), Ngaysinh, 113) as char) as Ngaysinh from casi where tencs like N'%" + txt_CS.Text + "%'";
da = new SqlDataAdapter(cs, cnn);
dtSP = new DataTable();
cnn.Open();
da.Fill(dtSP);
cnn.Close();
CollectionPager1.PageSize = 8;
CollectionPager1.DataSource = dtSP.DefaultView;
CollectionPager1.BindToControl = DataList1;
DataList1.DataSource = CollectionPager1.DataSourcePaged;
DataList1.DataBind();
Label1_ModalPopupExtender.Show();
if (dtSP.Rows.Count != 0)
return true;
else
return false;
}
protected void img_CheckCS_Click(object sender, ImageClickEventArgs e)
{
Checkcs();
}
If it's impossible. Is there another way to do it ? If it's possible. Can you show me an example code ? Any help would be great.
This is Sample. Please refer with this
.modalBackground {
background-color: Gray;
filter: alpha(opacity=80);
opacity: 0.8;
z-index: 10000;
}
.modalPopupCss {
background-color: white;
border-width: 1px;
border-style: solid;
border-color: #0066B3;
padding: 3px;
}
ASPX
<div>
<asp:ModalPopupExtender BackgroundCssClass="modalBackground" ID="Label1_ModalPopupExtender" CancelControlID="Button2" runat="server" Enabled="True" PopupControlID="Panel1" TargetControlID="lbl_CS"></asp:ModalPopupExtender>
<asp:Panel ID="Panel1" CssClass="modalPopupCss" runat="server">
<div style="margin-left: 20px; padding-top: 50px">
<asp:Label ID="lbl_CS" runat="server" Text="" ForeColor="#FF33CC" Font-Size="18" Visible="True"></asp:Label>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:GridView ID="GridView1" runat="server"></asp:GridView>
<asp:Button ID="Button2" runat="server" Text="Close" />
</div>
</asp:Panel>
<asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />
Aspx.Cs
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
dt.Columns.Add("ID");
dt.Columns.Add("Name");
dt.Columns.Add("State");
}
protected void Button1_Click(object sender, EventArgs e)
{
dt.Rows.Add("1", "Vignesh", "True");
GridView1.DataSource = dt;
GridView1.DataBind();
Label1_ModalPopupExtender.Show();
}