Reputation: 14296
I have this TextBox
:
<asp:TextBox id="locSelectedCameraGroupName" runat="server" ></asp:TextBox>
I have this back end code:
protected void btnCameraGroup_ServerClick(object sender, EventArgs e)
{
locSelectedCameraGroupName.Text = "test string!";
}
This method is called after clicking a button:
<asp:linkbutton id="btnCameraGroup" runat="server" onclick="btnCameraGroup_ServerClick" onclientclick="ShowCameraGroupPopup()"
style="font-size: 1.2em; text-decoration: none; cursor: pointer; background-color:grey; ">
<!-- TODO: Make button have round corners...css? -->
</asp:linkbutton>
However, the text does not update. This is a user control. The line is reached (according to my debugger). When I move the line to my page load, it works. Is there something wrong I am doing?
The following method ShowCameraGroupPopup
just shows/hides some tags I don't think it has much to do with the issue, but here it is anyways:
function ShowCameraGroupPopup() {
$('#<%=waitIcon.ClientID%>').show();
$('#<%=divMainContent.ClientID%>').hide();
$("#divCameraGroupPopup").modal("show");
return true;
}
This is the flow after clicking the link button:
Upvotes: 1
Views: 2503
Reputation: 14296
I needed an UpdatePanel (and ContentTemplate) around the TextBox with a Triggers (AsyncPostBackTrigger) as so:
<asp:UpdatePanel id="groupNamePanel" runat="server" updatemode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnCameraGroup" />
</Triggers>
<ContentTemplate>
<asp:TextBox id="locSelectedCameraGroupName" runat="server" ></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
Upvotes: 1
Reputation: 305
If you have Page_Load() event in your codes, change Page_Load() content like below:
private void Page_Load()
{
if (!Page.IsPostBack)
{
//copy previous page load codes here
}
}
Upvotes: 0