• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 415
  • Last Modified:

Ajax ModalPopup - Catch a button press

Hi
I have an Ajax ModalPopupExtender on a page.
To summarise ....
I have a link on a page, when I click the link the modal popup displays.
On this modalpopup I've a textbox and an 'ok' and 'cancel' button.

I wish to find out what was entered in the textbox when the button is clicked

I try the code attached but the value is null.

if (((TextBox)button1.Page.FindControl("theTitle")).Text == "")
               

Any ideas?
void okButton_Click(object sender, EventArgs e)
        {

            try
            {


                Button button1 = (Button)sender;

                //Dim ImageButton As imgBtn = CType(e.Item.FindControl("imgbtn_Zoom"), ImageButton);

                //TextBox theTitle = ((ImageButton)(e.Item.FindControl("theTitle")));


                if (((TextBox)button1.Page.FindControl("theTitle")).Text == "")
                {
                }
                else
                {
                }

                //Button button1 = (Button)sender;
                //((Label)button1.Page.FindControl("popupLabel")).Text = "Panel refreshed at " + DateTime.Now.ToString();



            }
            catch (Exception)
            {
                
                
            }


            



        }

Open in new window

0
hmcgeehan
Asked:
hmcgeehan
1 Solution
 
masterpassCommented:
just put

if (theTitle.Text == "")
// do rest
0
 
rajeeshmcaCommented:
HI hmcgeehan,

Is the Pop up shown is in the same aspx page where the clciked link is available or someother page...

If it is in the same page u can access the textBox Directly like
if(theTitle.Text == "")
{
}
0
 
hmcgeehanAuthor Commented:
If I do

if(theTitle.Text == "")
{
}

It does not compile

The name 'theTitle' does not exist in the current context

'theTitle' (the textbox) is on the ajax modalpopupextender

the modalpopupextender shows a textbox, an 'ok' button and a 'cancel' button.
When I click 'ok' then the event handler does fire

void okButton_Click(object sender, EventArgs e)

Thanks
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
masterpassCommented:
Is the modalpopup embedded in some kind of datalists ? like gridview, datalist, repeater ?

If it is so then you will have to use findcontrol with respect to the control used ...
0
 
rajeeshmcaCommented:
could u please post ur code
0
 
David RobitailleAnalyst ProgrammerCommented:
since you got
 Button button1 = (Button)sender;
 you could use

TextBox  theTitle = (TextBox) button1.Parent.FindControl("theTitle")
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now