Can't find the function body in ASP.NET - c#

I recently started working on a project that has been in development for some time now. The problem is this - in the web site page, a have a frame (amongst 4 others) in a frameset which contains the SVG map object (the whole site is GIS based). Also, in the same frame, there is a icon for opening the form in which user can choose a number of filters, and after he presses a button, the map refreshes and the area of influence around some key points on the map are drawn.
What i need to do is to open that form in a new (popup) window and not in the same frame where the map is. I did that this way:
onclick="window.open('zi.aspx','form1','width=700,height=500,left=350,top=100')"
This works fine. But then, when i enter the filters and hit Generate button, i get this error:
'parent.frames.map' is null or not an object
with the reference to zi.aspx. Now i know that this error is because i changed the form from opening in the same frame as map to opening it in a popup window, but i just can't find anywhere in the code where can i modify it. Before my changes, the code was just this:
onclick="showZi();"
and that is the function i can't find anywhere. Any ideas? How can i make this work, to make a map with filters drawn after the user has chosen appropriate ones from the popup window form? I should mention that this image link is in the ASP.NET table, with standard runat="server" command.

Okay, so you're opening a new window from javascript. Your problem is that you're trying to access the parent window by using the 'window.parent' property. This is wrong, you'll need to instead use 'window.opener' property. E.g.:
window.opener.frames.map

Related

How to propagate keystrokes to every frame in an HTML page?

My company doesn't allow me to show the code so I will describe it the best I can.
I have an HTML page containing 4 frames.
One on top containing the title and some other and the user's name
One one the bottom containing the version and other pieces of information
One on the left containing the menu
The last one is on the right and contains the content of the website.
Each frame contains an .aspx page. The page of the left frame doesn't change, and the one on the write is almost always changing. The 2 others don't matter.
I've been asked to add shortcuts leading to differents places. Those shorcuts will involve F keys. For instance, F1 will open the PDF help file in a new tab, F2 will lead to a certain page, etc...
I am using IE8 and I can't update it. And I know that some F keys are already used by it but I found a way to disable the functions called by them so that I can use them for my own shortcuts.
I tried to add the shortcuts in Javascript with a function which checks if a F key is pressed and released. I have successfully added this function in my left frame which always contains the same .aspx page, but as soon as I click on the right frame, it seems that I lose the focus on the other one and the shortcut doesn't work anymore. My problem is that in the right frame, about a hundred different .aspx can be called, so I can't add the Javascript function in each one. Moreover, I do not have access to the HTML page containing the frames, so I can not add the code here neither.
The best for me would be to be able to have the shorcut function in my left frame and that it is called even if the focus is on my right panel.
Do you know if a such thing is possible ? Or do you have any idea of any other way to solve this issue ?
Thanks.
(And forgive me for my bad grammar, english is not my native language)
You will need the functionality (ie JavaScript) repeated in every frame where you need it.
What you can do is create a base page and then inherit your ASPX pages from that, for instance:
public class PageWithShortcuts : System.Web.UI.Page
{
// Add JavaScript-outputting functions and other shared functionality here
private void Page_Load(object sender, System.EventArgs e)
{
RegisterStartupScript("mycode", "<script>...</script>");
}
}
Your pages then all inherit from this:
public class CheckoutPage : PageWithShortcuts
{
...
}

Navigation between pages in WP8.1

I'm trying to migrate my app from WP8 to WP8.1. And I don't get how to navigate to already opened page with another parameters.
For example, I'm showing user info on UserPage giving it user's id as parameter. And when page is already is the content of the Frame I want to open UserPage again but for other user giving it another id.
My problem is that, using NavigationCacheMode set to Required for UserPage means that there will be no navigation with other parameters. But when NavigationCacheMode is set to Disabled navigation with another parameter is success but when I press back button old instance of UserPage is using data from new one.
In WP8 passing new parameters was enough to create new instance of a page with it's own cache. How to do similar in WP8.1 using WRT APIs?
Thanks to Romansz for the tip about using UserControl. Using UserControl binding to a ContentControl and handling BackKeyPress solves my problem with navigation.

Open Popup in Second Monitor using ASP MVC

I've done a lot of research and am able to accomplish opening up a "form" or a "popup" in a second monitor. This is assuming that the user has a two monitor setup on their desktop.
The catch here is that I can only do it in a webforms application. I can set the StartPosition of the form that will be my popup to be Manual, and then setting the location through the Screen.AllScreens properties when it gets triggered in the parent form using a button. I am experimenting with providing the same kind of functionality but in an MVC app instead.
At this point, I am making a simple javascript call in my cshtml view to my controller to return a partial view and then displaying it in a new window as follows:
<script type="text/JavaScript">
var myWin = window.open('/HomeController/ActionThatGetsMyPartialView',"_blank");
</script>
And my HomeController has the method:
public PartialViewResult ActionThatGetsMyPartialView()
{
return PartialView("MyPartialView");
}
This is where I'm stuck. I'm not sure how I can control the location of the window that will be popping up. I know I can set the location of a window using javascripts Screen object, but this "Screen" object is I guess is not the same as the WinForms "Screen" object which gives me access to the monitors that the user has setup on their computer.
I don't know if this is a trivial thing, but my googlefu was not good enough to find anything that was targetting toward an MVC solution! Any help is appreciated.

ASP.NET Page loads slow as a popup, but not standalone link

Got a strange one, here.
I'm working on a basic ASP.NET/C# code-behind app where summary data is listed in a grid, and each record has an accompanying "update" button. Clicking the button triggers a window.open() where the ID for each row of the grid is passed into a query string to retrieve the related record for edit in the new window.
Example from the rendered "grid" page:
window.open('EditTool.aspx?ID=' + ID, 'new_window', width=550, height=300');
When the page opens from the button, it can take upwards of 10 seconds to render. When I open a new tab and just paste the URL and query string content into the address bar, the page renders almost immediately.
I've peppered the content of the page with log4net statements, and it looks like all of the controls and code-behind C# executes in a few milliseconds.
For investigation's sake, I've got popup blockers deactivated, and I've tried this on IE7 (workplace standard, ugh), FF, and Chrome.
Any ideas as to how to make the rendering faster, or where else I can look to see what's slowing it down?
Update:
I've created a new shell webapp that has a button opening an empty (just the stuff that gets added when you "Add New Item") ASPX as a popup. The popup renders immediately. I've also modified my existing app to open an empty popup, and I get the same delay. It's looking like the app server is waiting to process something before it starts processing the page, rather than rendering the page, slowly.
Does ASP.NET have a setting where you can tell it not to recompile a page on each render?

Why can't I see variables nor viewstates after partial postbacks in a webpart?

Something very odd is happening here.
I have a custom WebPart within Sharepoint which sends forms to Excel and by E-Mail. I'm using Asp.NET 3.5, Ajax, jQuery.
Inside OnInit() I'm connecting to TeamFoundation Server, opening an excel template, initializing jQuery, and loading up the css.
CreateChildControls() adds the controls to panels and such, and creates an empty literal i'm calling "litScript".
Inside PreRender(), I'm updating values based on partial (or not) postbacks and such. I also assign a value to litScript, which composes some layout rounding effect, a jQuery-based tab effect, and mouse-following progress icon.
I have many tabs with buttons which, upon clicked, process some stuff.
Upon assigning a random text "I'm here!" to a label inside some button click event, it reloads perfectly.
cc.GetTextControl("lblTeste").Text = myForm.PostbackMessage;
(cc.GetTextControl just returns my control).
However, by using my literal and writing
cc.GetTextControl("litScript").Text = "<somejavascript>"+myForm.PostbackMessage+"</somejavascript>";
I don't get anything.
When I do a full postback, everything loads correctly though.
What is happening?
Had something to do with javascripts not changing. I just added a RegisterClientScriptBlock and everything went fine.

Categories