Yes - it's deceptively simple. Just ignore theOnOKScript property and add a regular ASP.NET server side OnClick handler to your OK button.
Thanks,
Ted
I am new to the Atlas toolkit so please bear with me. I have a checkbox list residing within a ModalPopup control. The user can check of boxes and then click an Add To List button that fires a server-side function to add the values of those boxes to that user's profile. The control posts back just fine but the updated status of the checkbox list is not being sent back (e.g. none of the checkboxes are selected). What am I doing wrong?
Hi tolakc,
I can't really tell why this is happening from the information you've provided. Is the checkbox list inside an UpdatePanel with your button? Are you using an UpdatePanel at all to do this, or just regular postbacks? Perhaps you can post a small sample showing exactly what's going on.
Thanks,
Ted
I've been reading post after post on this subject and I'll give you a quick rundown of what I'm trying to do. The user clicks on a link and the modal popup window appears. It has a form on it that the user fills out. When they click the Ok button, I've created a btnOk_Click event handler and added code to take the variables from the modal popup and add the values to the Session object. The last line in the handler is to redirect to the next page that uses the variables. I've tried to debug it by putting a breakpoint in the handler, but it never hits the breakpoint. I've looked into calling the btnOk_Click handler via Javascript, but I can't figure it out.
Any Suggestions?
Thanks,
Eric
I had similar issues with this (we use VB.NET in our shop, it may be different in C#).
I found that in order to make the button handler fire, you need to associate the UniqueID of the button to the target argument of the postback, instead of the ID or the ClientID.
Not sure if this will help you.
I used the following script:
function postbackFromJS(sender, e) {
var postBack = new Sys.WebForms.PostBackAction();
postBack.set_target(sender);
postBack.set_eventArgument(e);
postBack.performAction();
}
Then in the codebehind (on PageLoad)
postbackButton.OnClientClick = String.Format("postbackFromJS('{0}', '{1}')", postbackButton.UniqueID, "")
Thunder3,
Thanks a ton for your post! I did what you did and now I can reach the event handler in debug mode! The values were passed through to the Session object, but I'm still having a problem with the final line:
Response.Redirect("FileUpload.aspx");
Nothing happens at this point and I am returned to the original page with the modal popup link. Why am I not redirected to the next page?
Thanks,
Eric
Thunder3,
Another thing that I just discovered. I put a breakpoint in the OnInit method for the "FileUpload.aspx" page and it was called. So from what I can figure, the redirect is working properly, there is just something else that is taking me back to the original page.
Any thoughts?
Thanks,
Eric
You may want to ensure that your Response.Redirect is not in a Try Catch block. Sometimes that can mess things up, especially with Sessions.
There may also be a condition on your other page that you have forgotten about that redirects back?
If you continue to have problems, try registering a redirect script block (javascript) onto the first page after you do the client side postback. This will ensure that the server performs a full round-trip (and stops doing funny stuff).
(Something like this):
function ProcessOrder()
{
location.href = "ProcessOrder.aspx";
}
setTimeout("ProcessOrder()", 1000);
I wouldn't go down this route unless its the only thing left though, it's not overly clean.
Perhaps try Server.Transfer as well.
I've trying to do the same thing with the modal dialog box posting back through an updatepanel. In IE, the event fires in code behind, but a javascript error occurs. Line:1 Char: 1 Error: Object expected. Then the button I use to open the dialog box stops functioning. In Firefox, I get the code behind to run, no javascript error, but the button doesn't work again. Awefully close here, but not quite. Maybe a little more help?
Rick
To be honest, I haven't tried the modal inside an updatepanel yet.
If you are getting a JS error in IE, it is likely that you are in FF as well, it is just not showing up because FF natively suppresses JS errors (they will appear in the Javascript console instead).
The error you are getting may be due to an error thrown on the server side. I think that they pass through the updatepanel and display as JS errors (I was having this for an incorrect key index problem earlier today).
Try stepping through right to the point it returns to the client to be sure it isn't a different part of your code blowing up.
Did you resolve this problem? I'm receiving the same error within IE. Within FF I get Error: Sys.WebForms.PostBackAction is not a constructor. Which makes me think that it can find the libraries. Would this be correct and if so how would I reolve it? I new to this whole thing, so at the minute I'm just guessing.
In the release version of Ajax, the PostBackAction is not in the Sys.WebForms namespace.
It was transfered to the Microsoft.Web.Preview.dll (Futures January CTP).
To use it,
- Install the ASP.NET 2.0 AJAX Futures January CTP.
- Reference it in your project.
- Reference it in the ScriptManager :
<Scripts>
<asp:ScriptReferenceAssembly="Microsoft.Web.Preview"Name="PreviewScript.js"/>
</Scripts>
</asp:ScriptManager>
- CallSys.Preview.PostBackAction() instead
Hope it helps.
Hi Guys,
I am using AJAX.NET 2.0 with Visual Web Developer.
My site has a master page. I have tried several different way to fire post back event on a Yesbutton click in modalpopup windows but no use.
I have also tried UniqueID method but no use always get the 'Error on Page'.
I have also tried to reference the button with 'ctl00_ContentPlaceHolder1_YesButton' in set_target method.
The Modalpopup windows code is as follows:
<asp:PanelID="ConfirmtionPanel"runat="server"CssClass="modalPopup"Style="display: none"><divclass="modalPopup-text">Are you sure you want to delete this item?
<br/><br/><asp:ButtonID="YesButton"runat="server"Text="Yes"OnClick="YesButton_Click"/> <asp:ButtonID="NoButton"runat="server"Text="No"/></div></asp:Panel><ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender1"runat="server"TargetControlID="DeleteButton"PopupControlID="ConfirmtionPanel"BackgroundCssClass="modalBackground"OkControlID="YesButton"OnOkScript="onYes()"CancelControlID="NoButton"DropShadow="true"></ajaxToolkit:ModalPopupExtender>
The script code is as follows:
<scripttype="text/javascript">function
onYes() {var postBack =new Sys.Preview.PostBackAction();postBack.set_target(
'YesButton');postBack.set_eventArgument(
'');postBack.performAction();
}
</script>
On Page Load:
Page.ClientScript.GetPostBackEventReference(Me, String.Empty)
Thanks in Advance
Do not set the OKButtonID to be the yes button and do not set the onok script. By setting that the modalpopup prevents the postback and just executes the onok script if set and hides the popup.
OkControlID="YesButton"
OnOkScript="onYes()"
No comments:
Post a Comment