Wednesday, March 28, 2012

Modal Popup Extender and set focus

I want to set focus on a textbox inside the modal popup extender when it is made visible and I cant for the life of me find an appropriate way to do this!

The popupcontrol is not good because when I add the attribute onclick it gets run before the textbox is made visible!

Any clues?

Cheers

Ross

Sorry, I hate to bump this but could really do with knowing how this can be done.

Ross


You can try registering a clientside startup script that sets focus to the text box. Or you can use the clientside script to open the modal popup and then set the focus.

#1:

page.ClientScript.RegisterStartupScript(me.getType(), "setfocus", "<script language=""javascript"">$get('textbox1').focus();</script>")

#2:

<script language="javascript">

function openModal(){

$find('modalpopupextender1').show();

$get('textbox1').focus();

}

</script>

The ids of the mpe and the textbox will need to be the client rendered id, so if you are using a masterpage or if this is in a user control, you will need to get the clientid from the server or from the output of the page prior to implimenting the code.

Let me know if need anyhting else.

-Alan


the solution in this article worked for me (although i would like to see something much better)

http://www.aspdotnetcodes.com/ModalPopup_Postback.aspx

then you add something similar to the following in the Page_Load event:

btn.Attributes.Add("onclick","fnSetFocus('" + control.ClientID +"');");


hi

go to the following link

http://forums.asp.net/t/1103365.aspx

No comments:

Post a Comment