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
{
...
}
Related
I'm exploring different options for .NET PDF libraries. One of my requirements is to place a box at the bottom of the first page and if any of the content reaches the box, it should overflow onto the next page.
For example:
Shown above, paragraph 7 would normally take up some of the space that's occupied by the "reserved" area. Instead, the part that would have taken up that space is shifted to the next page.
That image was achieved using Gembox.Document by adding the box as a footer element that only renders on the first page. However, in iText7, the examples I've seen for adding a footer (such as this one), places the content as a floating element that renders over the existing content and does not affect the layout/flow of the rest of the document.
I also tried adding a paragraph on the PageEnd event handler without the canvas (snippet below), but instead of adding it to the specified page, it's added to the end of the entire document.
public void HandleEvent(Event evt)
{
var docEvent = (PdfDocumentEvent)evt;
var page = docEvent.GetPage();
int pageNum = docEvent.GetDocument().GetPageNumber(page);
if (pageNum == 1)
{
doc.Add(new Paragraph("Testing a thing"));
}
}
Is the type of effect I'm looking for something that I can replicate using iText7?
I believe you can combine the concepts of https://github.com/itext/i7ns-samples/blob/develop/itext/itext.samples/itext/samples/sandbox/acroforms/AddExtraTable.cs and https://github.com/itext/i7ns-samples/blob/develop/itext/itext.samples/itext/samples/sandbox/events/TextFooter.cs to achieve what you need.
The idea is as follows:
reserve place for your box by making iText give the document's renderer less space for the first page
fill this box with a help of iText's end page events
Another option was suggested in How can I insert an element to the bottom of a specific page in iText7? : you can temporary call Document#setBottomMargin , since elements added via Document#add will not be placed on margins. Then, once the first page is layouted, you can set the initial margins again. This option, however, requires understanding of you layout flow, since the margins should be set only after the content of the first page is layouted.
One more suggestion: althouth event functionality is rather flexible and useful, it seems like using a sledgehammer to crack a nut. You need to call Canvas#ShowTextAligned, which could be done without any event handling. So ideally I would prefer to do the following:
handle page's layout area via an extension of DocumentRenderer
Calling Canvas#ShowTextAligned to fill the reserved box.
As you said, you are exploring different .NET PDF libraries. So I would advise PDFFlow library, which does exactly what you need.
If you have a footer, main document flow will take the rest of page area and will be automatically continued at the next page without overlaying footer.
DocumentBuilder.New()
.AddSection()
.AddParagraph("long text")
.ToSection()
.AddFooterToBothPages(40)
.AddParagraph("this a footer set for each page of this section")
.ToDocument()
.Build("result.pdf");
Here is a tutorial with code examples of using headers, footers, left/right repeating areas: AddingRepeatingArea tutorial.
Hope, this will help you :)
So, I've seen many discussions that are in this area, but it seems like they are mostly discussing Windows Forms, or they don't get around to answering this specific scenario enough to point me in the right direction.
Exactly what I need to do (Generic Example):
HTML (fragment.aspx)
<div id="html_fragment_1" runat="server">Contents</div>
<div id="html_fragment_2" runat="server">Contents</div>
...
Code Behind (fragment.aspx.cs)
Fragments fragment = new Fragments();
fragment.return_fragment( AN INSTANCE THAT REFERS TO html_fragment_N );
Class (Fragments.cs)
public void return_fragment ( AN INSTANCE THAT REFERS TO html_fragment_N ) {
string html = INSTANCE.html_fragment_N;
// DO SOMETHING WITH html
HttpContext.Current.Response.Write(html);
}
The reason I need to do this is that every aspx form on my site needs to be manipulated in the same way by Fragments.return_fragment(), where the content for several DIVs need to be read from the Form and arranged into an XElement to be returned.
Instead of doing the manipulation in the CodeBehind for every page, I'd rather have each Form use Fragments.return_fragment() so that it saves effort implementing a new Form page, and the code can be changed easily without having to change it in each Form.
Looks like you want your app's Global.asax file:
http://msdn.microsoft.com/en-us/library/1xaas8a2(v=vs.71).aspx
Look at your app's page events here as a place to specify things that should happen on every page request.
I'm creating a WP7 application using C#, and I require to pass data from one page to the other.
I found solutions on SO, but I'm still running into problems.
On 'Page 1', I wish to display a list, that can be populated by the user, using input from 'Page 2'.
I used the following statement in 'Page 2' while navigating back to 'Page 1': NavigationService.Navigate(new Uri("/MainPage.xaml?text="+WhoBox.Text, UriKind.Relative));
WhoBox is a Text Box.
On 'Page 1', I have the following:
protected override void OnNavigateTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (NavigationContext.QueryString.ContainsKey("text"))
ListBlock.Text = ListBlock.Text + NavigationContext.QueryString["text"];
}
Now, this works, but in a limited fashion. If I try adding something from 'Page 2' for a second time, it replaces what is present in ListBlock (which is a Text Block) with the newly added text instead of appending it.
Shouldn't ListBlock.Text = ListBlock.Text + NavigationContext.QueryString["text"]; cause the new text to be appended, rather than to entirely replace the older text?
EDIT: I may have found the solution. For whatever reason, no changes in the XAML or .cs file are reflected when I run the program using F5. Am I doing something wrong? For example, even if I delete a button, it still appears when I Debug (F5) the program. Is there some setting I need to change? Or am I supposed to use some other command? I'm relatively new to Visual Studio, so please excuse me.
The problem is that the moment you again leave your page 1 it is basically disposed of. Meaning any text that was set in the Listbox is also removed. You will , in other words, need to save the state of that page before leaving it.
There several possibilites here:
Use AppSettings (see Windows phone 7 config / appSettings? )
Write the state to a local database
Do a quick'n dirty fix by saving the Text in the App.xaml.cs which all pages can work with: First you need to create the application-wide variable (and initialize if needed) inside the app.xaml.cs file. For example:
public partial class App : Application
{ public string myText;
From now on you can reach any App-variable through the Application.Current object. So if you need to access bigVar from some page in you application (e.g. MainPage) you simply type:
string Text = (Application.Current as App).myText;
Consider using sessions and datatable: Storing and retrieving datatable from session
I'm trying to teach myself C# and to start I'm trying to convert a program I originally wrote in Autoit.
I'm using a Windows Application Form and the program is suppose to take one or two links as input. Navigate to those to pages, grab some links from a table, then visit each of those pages to grab some content.
If only one link is entered it seems to go to that page and grab the links from a table like it is suppose to. If two links are entered it seems to only grab the links from the second table.
So if two links are passed this method
private void getPageURLList(string site1, string site2)
{
getPageURLList(site1);
getPageURLList(site2);
}
Calls the same method that gets called when there is only one link
private void getPageURLList(string site)
{
webBrowser.DocumentCompleted += createList;
webBrowser.Navigate(site);
}
I'm pretty sure the issue is "Navigate" is getting called a second time before createList even starts the first time.
The reason I am using WebBrowser is because these pages use Javascript to sort the links in the table so HTTPRequests and the HTMLAgilityPack don't seem to be able to grab those links.
So I guess my question is: How can I keep my WebBrowser from navigating to a new page until after I finish what I'm doing on the current page?
You have to make a bool variable to know when the first proccess has completed. And then start the other. Application.DoEvents() will help you.
Note that all this events run in the main thread.
In your documentcompleted event you do your link processing. At the end of the link processingyou tel the browser to navigate to the next url
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