Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7946179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:04:34+00:00 2026-06-04T01:04:34+00:00

I am having trouble with making my button perform a click after a postback.

  • 0

I am having trouble with making my button perform a click after a postback. I am validating some textboxes within a modal window on a web page, which only appears after a button click. Currently after the postback the web page re-opens and the modal window is closed, which is required to be open. There is no handler in my code, the button is clicked and runs html code to bring up the modal window. I need this button to perform a click once i have posted back so that the validation is initiated. I have tried using btnSickness.Click() but it does not seem to like this and can’t seem to find anything anywhere! Code:

public partial class _Default : System.Web.UI.Page
{

    int i = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (i > 0)
           {
           }      

    }

    protected void chkDoctor_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (drpDoctor.SelectedValue == "Yes")
        {
            txtIfNoWhy.ReadOnly = true;
            txtIfNoWhy.BackColor = Color.LightGray;
            i++;
        }
        else if (drpDoctor.SelectedValue == "No")
        {
            txtDocName.ReadOnly = true;
            txtHouseName.ReadOnly = true;
            txtStreet.ReadOnly = true;
            txtTownCity.ReadOnly = true;
            txtCounty.ReadOnly = true;
            txtPostalcode.ReadOnly = true;
            txtInitialDate.ReadOnly = true;
            txtTreatmentRecieved.ReadOnly = true;
            txtCurrentTreatment.ReadOnly = true;

            txtDocName.BackColor = Color.LightGray;
            txtHouseName.BackColor = Color.LightGray;
            txtStreet.BackColor = Color.LightGray;
            txtTownCity.BackColor = Color.LightGray;
            txtCounty.BackColor = Color.LightGray;
            txtPostalcode.BackColor = Color.LightGray;
            txtInitialDate.BackColor = Color.LightGray;
            txtTreatmentRecieved.BackColor = Color.LightGray;
            txtCurrentTreatment.BackColor = Color.LightGray;
            i++;
        }
    }
}

Modal window code:

<div class"modal" id="myModal"></div> 
    <div class="row-fluid">
        <div class="span2">
                <asp:Button runat="server" class="btn" data-toggle="modal" href="#Div1" ID="btnSickness" Text="Submit a Sickness Form" />
                       <div class="modal hide" id="Div1">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h3>Sickness Form</h3>
</div>
<div class="modal-body">
<p>Please fill in the following information regarding your sickness</p>
<br />
<p>Sickness Date From:</p>
<asp:TextBox runat="server" ID="txtSicknessFrom"></asp:TextBox>
<br />
<p>Sickness Date To:</p>
<asp:TextBox runat="server" ID="txtSicknessTo"></asp:TextBox>
    <br />
<p>Absence Date To:</p>
<asp:TextBox runat="server" ID="txtAbsenceFrom"></asp:TextBox>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:04:35+00:00Added an answer on June 4, 2026 at 1:04 am

    You can set a hidden field to tell the modal to show when you return from the server. Then you can add a pageLoad javascript function, which runs every time the pageLoads, to check if you need to show the modal.

    Serverside:

    hdf_ShowModal.Value = "true";
    

    HTML:

    <asp:HiddenField runat="server" ID="hdf_ShowModal" />
    

    Javascript:

    function pageLoad(sender, args)
    {
        if(document.getElementById('<%= hdf_ShowModal.ClientID %>').value == "true")
        {
            // perform code to show modal
        }
    }
    

    Edit:

    Since you are using jquery as well, you can try the following to show the modal:

    function pageLoad(sender, args)
    {
        if($('[id$=hdf_ShowModal]').val() == "true")
            $('#myModal').modal({ show: true });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble making this work: $(function() { $(.button).click(function() { var newentry = $(input#entry).val();
Im having trouble making sure my active graphic is positioned outside of the button,
I've created this simple demo because I'm having some trouble making auto-sizing work in
For some reason, I'm having trouble with making a textfield the first responder. I
I'm having some trouble with an iPhone app that I'm making. I have two
I am having trouble making this work and am looking for some help. Currently
Maybe a simple question but I'm having alot of trouble making a button change
I'm having trouble doing scrolling...What I want to do is after clicking a button
Im having trouble making my table contents vertically aligned and was wondering if you
I'm having trouble making a secure FTP connection using SharpSSH. Up to now I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.