Showing posts with label popup. Show all posts
Showing posts with label popup. Show all posts

Monday, March 26, 2012

Programmatically trigger modal popup

I want to write a page that checks for a cookie via Javascript and then possibly opens a modal dialog box. How do I trigger the modal popup via client side javascript?

I saw the example that comes on the modal dialog that sample page, however that works with a client side event such as a click. Can I do it without listening for an event?

Hi theregit,

In the javascript where you check the cookie, you can trigger a button.

That button's click event can then be another javascript that opens a modal window.

Trigger the button like:
var myButton = document.getElementById('myButton');
myButton.click();

Is this an answer to your question?
if you have comments/remarks/questions .. please do so!

Kind regards
Wim


Try this ,

Show and Hide ModalPopupExtender from JavaScript

Hope this helps


Phanatic,

Thank you sooo much for that post. I was having the problem with the 'null' is null or not an object error. Once I used the pageLoad() method it worked great.

Protecting javascript based on role

To set up what i am going to ask, allow me to explain the page:

I've got a page that shows reports with a popup panel that has all sorts of options on it.... when i first load the page, i show/hide/fill these options based on Roles

The page does not do any post backs, just javascript calls to webservices and i show the report data based onthis blog post by Scott Guthrie (using a page instance, a user control and generating/grabbing the HTML)....

In the aspx markup of the page is hundreds of lines of javascript i have written over the past week, and what i am realizing is that all the script is there for the world to see regardless of role....

So where i may say: $get('drpManager') , that is a control that is only available to certain role (i set visible and enabled to false if the user isn't allowed to see it), but just seeing that in the code, a malicious user may be able to figure out how to do something that they shouldn't be allowed to...

So what I am asking/wondering is maybe some ideas to package the javascript, broken up into role specific functionality, into the page execution and spit it out (this cried out WebResource and ScriptManager.RegisterScript) based on role

Any thoughts on this or pointers?

Unfortunately ( and I hope someone with greater knowledge than I will lambast me for saying something inaccurate)... is no - there is no such thing as security when it comes to scripts. This is the only primary reason I handle everything from the server side when it comes to security specific issues...You can however authenticate using the profile feature of Ajax...but even if you use any of the number of javascript encryptors available (most will not work with Ajax anyways). You will be exposing your logic to those whom realize that you are doing something sensistive..

Naturally you could could create seperate javascripts depending on the role it would be more secure - but if you are using anything Ajax in a security related enviroment - it is my recomended best practice handle it serverside and not clientside... the less the client knows what is going on means the less a hacker knows what is going on... Ajax is afterall just a tool... and security wise - its is the the subject of numerous related security articles because there really is no framework to protect against plain text script... but I would not rely on a global and executing based upon parameters sent to the client on the client...if you must and refuse to do the stuff server side and take the perf hit while maintaining the ajax ui glitz for the customer... then send only the scripts to the client that are related for the role they have...


jodywbcb:

then send only the scripts to the client that are related for the role they have...

Apparently you missed the whole entire point of my topic and the question i asked at the very end, as the above line by you that i quoted is exactly what i was asking for ideas onhow to do...

I wasn't asking for page architecture advice... the page is big and it's fast as hell and getting/updated/refreshing sections of the report piece by piece via AJAX, which absolutely is the best way for this page to serve it's existance, now i am just asking about steps, even if it's just a little step, on keeping code out that a lesser role doesn't need

Wednesday, March 21, 2012

Question About using a modal popup for each row in a gridview

Hello, I'm trying to have a modalpopup control fire in a gridview, but I dont know how to approach the problem. Basically I have a linkbutton in each row of my gridview. The code for this is:

<asp:ButtonField HeaderText="Primary Subject" SortExpression="subject" ButtonType="Link" commandname="Subject" DataTextField="subject" />

which does not have an ID attribute, but of course modal popup control needs the attribute TargetControlID="something"

How do I make the buttonfield have an id? or be able to use it inside a modal popup?

Thanks

Use a TemplateField with a LinkButton instead.


Question About using a modal popup for each row in a gridview

Do you really need the trigger (the button is inside the panel, so it should trigger without it)?

Does it work if you remove the Popup extender?

Question on DynamicUpdate properties...

When using this feature - my understanding is that the principle around it is to use a web service.

Say for a popup form modal or otherwise... one was to use it...

how do you go about setting security principles and otherwise preventing someone that shouldn't have access to it beyond the mere fact you can authenticate prior to...my concern is security using this feature...are there any examples to look at that do not use the profile services that guards against someone using a tool like fiddler from manipulating and querying or otherwise being able to submit when using Atlas dynamic behaviors in this manner?

I'm not sure I understand what security issues you feel DynamicPopulate introduces (that aren't already present). Could you outline a scenario, perhaps?

Question regarding updatepanel and modal popup

Good morning everyone I have a question regarding a page that I am working on at the moment. My project uses one masterpage. On this masterpage I have placed a modal popup extender which is called from several content pages. On one of my content pages I have placed an update panel. When I call the show method of the modal popup extender from the update panel the data that is being retrieved in the modal popup, does not appear. I have tried removing the update panel and calling the show and it works fine. What exactly am I missing or not doing?

Thanks in advance.

Wrap the ModalPopupExtender's Panel with another UpdatePanel.


Thank you for your response, I appreciate it. I did actualluy figure out that this was the cause.