vim
vim

Reputation: 864

Link button inside update panel is not working

I have two link button inside the update panel. If I click on first link or second link then first time it is working but second time it is not responding. Here is my aspx code

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <table style="width: 80%;" runat="server" id="addAnounce">
          <tr>
            <td style="width: 50%; padding-left: 10px;">&nbsp;<asp:Label runat="server" Text="Message Text" ID="Label8"></asp:Label>
            </td>

            <td style="width: 50%">
              <table>
                  <tr>
                      <td style="width: 60%">
                          <asp:TextBox ID="txt_Message" runat="server" MaxLength="2000" Height="100px" TextMode="MultiLine" Wrap="true" Width="121%"></asp:TextBox>
                      </td>
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txt_Message" Display="Dynamic" ErrorMessage="Messgae Text is Mandatory." ValidationGroup="Reg"  ForeColor="Red" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                      <td  style="width: 40%"; align="right";>
                          <asp:LinkButton ID="LinkRiverBasin" runat="server" Text="River Basin" OnClick="LinkRiverBasin_Click"></asp:LinkButton><br /><br />
                          <asp:LinkButton ID="LinkState" runat="server" Text="State" OnClick="LinkState_Click"></asp:LinkButton><br />
                      </td>
                  </tr>
              </table>
          </table>
      </ContentTemplate>        
  </asp:UpdatePanel>

CS page is :

protected void LinkRiverBasin_Click(object sender, EventArgs e)
{
    txt_Message.Text = txt_Message.Text + '\n' + "<River Basin>" + '\n';
}

protected void LinkState_Click(object sender, EventArgs e)
{
    txt_Message.Text = txt_Message.Text + '\n' + "<State>" + '\n';
}

Upvotes: 1

Views: 655

Answers (3)

Nazir Ullah
Nazir Ullah

Reputation: 610

Add the below line of code in web.config for allowing this characters

  <pages validateRequest="false" ></pages>

Upvotes: 1

dawncode
dawncode

Reputation: 618

Because you making use of "Potentially Dangerous Characters" remove "<" and ">" characters and it will work.

follow this http://tldp.org/HOWTO/Secure-Programs-HOWTO/cross-site-malicious-content.html

Upvotes: 1

Nazir Ullah
Nazir Ullah

Reputation: 610

This is the issue of angle braces with CS code replace the code behind code with this one

  protected void LinkRiverBasin_Click(object sender, EventArgs e)
        {
            txt_Message.Text = txt_Message.Text + '\n' + "River Basin" + '\n';
        }

        protected void LinkState_Click(object sender, EventArgs e)
        {
            txt_Message.Text = txt_Message.Text + '\n' + "State" + '\n';
        } 

Upvotes: 1

Related Questions