Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Wednesday, March 28, 2012

Modal Popup causing double page load

I'm having a problem where it seems that the Modal Popup is causing my pages to double load. I have a simple Master page file which just has my modal popup on it and my pages create the event handlers for the images on the modal popup. When i put a break point on page load i can clearly see that my pages are loading two times.

I'm wondering if anyone else has had this problem and if so is there a simple solution?

Thanks,
Kam

I seem to have answered my own question. I had ImageButtons inside the target panel and those were causing the page to load twice. when i set the visible to false so that they don't render on the page the page doesn't double load.

This might be a bug. Can someone else test it and see if you get the same results?

Thanks,
Kam


I also have a similar problem. I didnt understand all of your answer.

I have a modal popup with an updatepanel with 2 DDL's, 2 image buttons

and 2 text boxes..the DDL's and text boxes have theirautopostback=false

and the DDL's also havecausesvalidation=true.When I click either button,

the code behind fires twice..?? Happy to post the markup if you want..when

do you set thevisible=trueon your buttons? How does that cause a double load?

Thanks..


This can occur if the page is the default page for the application (e.g. default.aspx) and an image or imagebutton is missing the imageurl attribute.

Ok..no help for me..I'm not on the default page, and

my urls are specified..any idea why the code behind

for the 2 imagebuttons fires twice for each click?

Thanks..


Could also be due to a double up with autoeventwireup and manual wiring up of the events:http://forums.asp.net/thread/1287221.aspx

Jason:

I left a detailed response for you at the same link.

Spent the entire weekend trying to get it going by all

combinations of true & false for both the page and the control..Tongue Tied

no luck..Crying

http://forums.asp.net/thread/1287221.aspx

Thanks for your input..Cool

Modal Popup Extender blinks on page on initial page load

Hello,

I am getting some undesirable behavior from the modal popup extender control. Everything works fine except for the fact that when i load or reload the page, you can see the modal popup box at the bottom of the page blink for about 1 second and then disappear. Why does it do this? Has anyone else seen this before? I would rather not see the box blink at the bottom of the page when loading the page, it just looks weird. Other than that, it appears fine when i click my button. Its just annoying to see it on the page load.

Any ideas here?

usually you need to set the style='display:none'


awsome...that did the trick...in the panel tag i did this:

<asp:Panel ID="pnlModalCheckUser" runat="server" Height="110px" Width="250px" CssClass="modalPopup"style="display:none">

even though style didn't come up as a valid property for the asp:panel tag in intellisense. But it works, i'm assuming it just passed the style along to the processed div tag.

Thanks a bunch!

Monday, March 26, 2012

Modal Popup from code behind

I'm having issues trying to load a Modal Popup from a OnClick event from an Image Button. This code goes through and actually runs the sub from the code behind file, but when the page actually finishes loading the modal popup does not show up, it basically just refreshes my page. Can anyone tell me what I'm doing wrong? I'm needing this to work because eventually I'm going to be putting this into a repeater for a bunch of image thumbnails, on click of a particular thumbnail it will load a modal popup with a larger image and some text information.

In my actual file (code below is in a test page without the repeater information), I have the same code but add in my repeater code around it, but on button click it won't even fire the sub from code behind, it simply does a page refresh and thats it.

If I can get this test page to work, then maybe the other will fall into place too.

Frontend Code:
1 <asp:scriptmanager runat="server"></asp:scriptmanager>
2
3 <asp:ImageButton runat="server" ID="test" OnClick="myRun" ImageUrl="/my.jpg" />

4 <asp:Button ID="btnShowPreview" Visible="False" runat="server" Text="Button" />
5
6 <%--Designs--%>
7 <asp:Panel ID="pnlPreview" CssClass="popupModal" Style="display: none;" runat="server" Width="600px">
8 This is the panel.
9 </asp:Panel>

Backend Code: 
1Sub myRun(ByVal SourceAs Object,ByVal ArgsAs ImageClickEventArgs)2Dim modPreviewAs New AjaxControlToolkit.ModalPopupExtender34 modPreview.ID ="mpePreview"5 modPreview.TargetControlID ="btnShowPreview"6 modPreview.PopupControlID ="pnlPreview"7 modPreview.BackgroundCssClass ="modalBackground"9End Sub
Hope you can help.
Micah

In your codebehind you are just creating the popup extender, you aren't showing it.
You need to call .Show() when you've created it.

Btw, you don't need to create it in codebehind. Create in your .aspx instead and just call Show() on it.


Good call on that one, I was thinking about it later that night to and couldn't figure out why I was doing it from code behind.

I moved the model popup extender to .aspx page and call the mpePreview.Show() from code behind, it does run through the code still, but never displays the modal still.

Any other suggestions? Do I need to have certain properties set on my modal and scriptmanager that I'm missing?

Thanks for the help

MIcah


Ah ha, kind of figured it out, my hidden button is causing the issue, if I make my button visible it works, if I make it invisible it fails.

So now I just need to figure out how to hide my control and have it still fire correctly.


style="display: none;"

will hide effectively.

<asp:Button runat="server" ... style="display: none;" />

Intellisense won't pick it up but you can put it there.


Ahh, sweet that worked perfectly! I hadn't even thought about that option.

Great, Thank you very much.

Micah

Saturday, March 24, 2012

Modal popup visibility and background...

My ModalPopup panel is being visible before its disappears..

It flicks on the screen int the HTML load...
How can I fix this?

And...What is the style of modalPopoupExtender demo in atlas control toolkit site?

How can I make one similiar?

thanx!Please see FAQ #1 (http://forums.asp.net/thread/1293293.aspx#1) and StyleSheet.css in the root of the SampleWebSite.
Hi...Thanx...
BUT...I got three problems...

First...modalBackground stylesheet doesn't work in Firefox..because opacity and filter properties...
and..
Second...modalBackground stylesheet doesn't work with Dropdownlist control..it remains with default style...

finally...my last problem is that style="visibility:false;" doesn't work...

I just want to make something similiar to Insert Code modal of this page...with all components behind disabled and with low opacity...and it is hide on pageload =D..
this can't be so difficult...I also would like to load my usercontrol inside the modalpopup panel...BUT...is very difficult work with updatepanel and modalpopup together...

here is my code:

"DivRegisterUnit" style="visibility:false;"> "LabelUnitID" runat="server" Text="ID:"> "TextBoxUnitID" runat="server"> "LabelUnitDescription" runat="server" Text="Descri??o:"> "TextBoxUnitDescription" runat="server"> "ButtonRegisterUnit" runat="server" Text="Salvar" />

"MpeRegisterUnit" runat="server"> "modalBackground" OkControlID="ButtonRegisterUnit" PopupControlID="DivRegisterUnit" TargetControlID="LinkButtonRegisterUnit" />

<div id="DivRegisterUnit"> <asp:Label ID="LabelUnitID" runat="server" Text="ID:"></asp:Label> <asp:TextBox ID="TextBoxUnitID" runat="server"></asp:TextBox> <asp:Label ID="LabelUnitDescription" runat="server" Text="Descri??o:"></asp:Label> <asp:TextBox ID="TextBoxUnitDescription" runat="server"></asp:TextBox> <asp:Button ID="ButtonRegisterUnit" runat="server" Text="Salvar" /> </div> <cc1:modalpopupextender id="MpeRegisterUnit" runat="server"> <cc1:ModalPopupProperties BackgroundCssClass="modalBackground" OkControlID="ButtonRegisterUnit" PopupControlID="DivRegisterUnit" TargetControlID="LinkButtonRegisterUnit" /> </cc1:modalpopupextender>

Hi...
I resolved two of my three problems :P

First...I was wrong...
Third...I used "visible:none;"

the only one that I can't fix was the dropdownlist problem...

thanx..
If the issue is that the dropdown remains visible when the ModalPopup is displayed, the reason can be found in the FAQ. Our next release will have a workaround for this; you can get the code from CodePlex now if you want to try it out early.

Modal Poup on Page Load

Hi,

Is it possible to conditionally show modal popup on a page load instead on button click?

Before the page load, I have to check from the database if the application is available and if the application is not available then I have to show the modal popup otherwise not.

Please answer with an example.

Thanks

just write the ModalPopup.Show(); on page load.

Thanks

PS If it answers your question, please mark this post as resolved for everyone's benefit.

Wednesday, March 21, 2012

ModalPopup

I would like to be able to load the contents of a modal popup when the popup is activated. As far as I can tell, the data to be loaded (from a database) currently happens as the entire page is rendered. What I would like to happen is that the data is loaded from the databaseonly when a popup is selected.

Is this possible without a lot of effort? Can someone point to or post some sample code for this? Is this a planned feature in a future release?

Any assitance greatfully appreciated.

Adam

I do something sort of like what ur asking in my apps.

I put the modal in an updatepanel along with the button (or whatever control I have that trigger's the modals opening) and then on the server I load the popup's contents and then open it from the server using it's Show() method.

That's probably the best u can do, either way your going to have to go back to the server to load up the modal's content's so I'd say that solution should serve you well enough.


Thanks for the reply - are you able to supply an example of what you do? I'm still trying to get my head around all of these controls ...


If you just want to display content, then you could also use the Dynamic* properties of the modalpopup to call a web service method which will load the content only when the popup is shown. However, this will not work if you want server controls in the modalpopup.

For Sam's method, you need a button on the page with style="display:none;" and use this as the targetcontrolid of the modalpopup. Then let the control that will show the modalpopup postback to the server and in the event handler for that control, load the modalpopup content and call the Show() method.

Jason


All aussie thread!

Sorry Adam, but I've abstracted this scenario out into some reusable libraries so I don't have any code that demonstrates it easily.

This isn't so much of an example as a few snippet of code I have. Heres how ur button should look:

LinkButton dummyButton =newLinkButton();
dummyButton.EnableViewState =false;
dummyButton.Style["display"] ="none";
dummyButton.ID = idPrefix +"DummyButton";

You then point the TargetControlId property of the popupmodal at the dummybutton's id. This gets you around the annoying need for a button reference to exist.

Why oh why didn't they decide to extend an Panel instead of a Button?!?!

Then just call the popupmodals Show/Hide methods.


East coast massive!

Yeah...couldn't agree more. The panel is the the logical choice for the targetcontrol of the modalpopup with a button being an *optional* trigger control to show the modalpopup.


Hi,

I believe this question can be perfectly solved with either Sam's or Jason 's suggestion. But I still want to extend Jason's post by providing a small sample.

The idea is to register a showing event handler to the ModelPopupExtender on client side. In the handler, call a web service( I used a page method here ) to fetch data from server and fill the result in a DOM element( which is the rendered result of a web control ) . Here is it:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
protected void Page_Load(object sender, EventArgs e)
{
}

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string AccessDB()
{
// code to access database here
return "The result retrieved from database on" + DateTime.Now.ToString();
}

</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"EnablePageMethods="true">
</asp:ScriptManager
</div>
<asp:Button ID="Button1" runat="server" Text="Popup via client" />
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></asp:Panel>
<ajaxToolkit:ModalPopupExtenderBehaviorID="mpe" ID="ModalPopupExtender1" PopupControlID="Panel1" runat="server" TargetControlID="Button1">
</ajaxToolkit:ModalPopupExtender
<script type="text/javascript"
Sys.Application.add_load(modalSetup);

function modalSetup()
{
var modalPopup = $find('mpe');
modalPopup.add_showing(accessDB);
}

function accessDB()
{
PageMethods.AccessDB(onComplete);
}

function onComplete(result)
{
$get("TextBox1").value = result;
}

</script>
</form>
</body>
</html>

Hope this helps.



Hi Raymond,

I think it would be better to use the Dynamic* properties of the modalpopup rather than manually hooking up the showing event. This will reduce the amount of code you have to write to achieve the same result.

Jason


Yes, it's a better idea.

ModalPopup -> UserControl -> fire event ?

Hello !

Because I made different scenarios with modalpopups, I have this situation :

1) I create ModalPopup dynamically

2) Load dynamically a usercontrol into a ModalPopup (and set usercontrol ID)

3). UserControl has buttons OK,Cancel and btnFireClick with click event on a server

Everything is fine, except that when I click btnFireClick the click event didnt fire...

If I set the same buttons into modalpopup but not like usercontrol - event is executed

If I load the usercontrol in the page (not in modalpopup) - event is executed

But if I load usercontrol into modalpopup - event didnt execute

Where is the problem ?

I use Microsoft ASP.NET 2.0 AJAX Extensions

Please try your scenario with the recently available61121 release of the Toolkit (and ASP.NET AJAX Beta 2). If the problem persists, then please reply with acomplete, simple, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

2) Load dynamically a usercontrol into a ModalPopup (and set usercontrol ID)

Your user control is a server side control which renders a bunch of html controls at the client side, it is not like a Panel server control which renders a div at the client side.


The second thing you may want to look at is, if you load the user control dynamically, you will have to load the user control every postback within OnInit or OnLoad and give it the same name since you the first time you load the user control dynamically. Otherwise, the event won't fire and the control does not even exist.