I have a ASP.NET / C# page where there are multiple tables with an image being loaded into the header. These tables are added dynamically to the page (via the c# code-behind). The images are supposed to be Tool-Tipped with some text, but the tips are not showing up when floating the mouse over the image.
The table is built using this basic concept:
//TABLE CREATION CODE
Table t = new Table();
TableRow tabrHeaderRow = new TableRow();
TableCell tabcHeaderCell = new TableCell();
//IMAGE CODE
System.Web.UI.WebControls.Image im = new System.Web.UI.WebControls.Image();
im.ImageUrl = #"~/img/HEL-icon.png";
im.ImageAlign = ImageAlign.Right;
//im.**add tooltip**
//Add Image to header of table
tabcHeaderCell.Controls.Add(im);
TableCell tabcHeaderCell2 = new TableCell();
tabrHeaderRow.Cells.Add(tabcHeaderCell);
tabrHeaderRow.Cells.Add(tabcHeaderCell2);
t.Rows.Add(tabrHeaderRow);
Attempts for adding tooltip:
im.ToolTip = "TipThisPlz";
im.Attributes.Add("alt", "TipThisPlz");
im.AlternateText = "TipThisPlz";
I have tried various approaches and none seem to get the tooltip to display. Every time, the image will appear, and when I "ViewSource" on the page, it loads correctly and shows either the "alt" or "title" property as being set, but the ToolTip will never display when floating the mouse over the image.
I did some brief experimentation with the "z-index" property, but it didn't seem to help me at all.
Any suggestions on what could be causing the ToolTip not to display when being dynamically added?
NOTE: Adding an < ASP:Image> to the markup with an AlternateText works perfectly fine on the page.
BROWSER OF INTEREST: IE9
It turns out that there was a some CSS effecting the layering of the controls. Therefore, the image was not able to have the mouse float over it since it was in the back and the table was in the front.
The "Z-Index" was the property that was preventing the tooltip from displaying.
Related
I'm creating a PdfFlowDocument using Xfinium.PDF for UWP. I need to insert a page break but only if a certain section (containing paragraphs and tables) does not fit on the current page. It's a kind of "keep together" feature.
How could I accomplish my task?
UPDATE: I've minimized the amount of content that I need to keep together to just a single table. Although it is a flow table, I understand I will need to convert it to a fixed-sized table to calculate its height. If I could somehow find out the current position on the page after rendering all flow content, I would be able to calculate how much space left on the page. If there is enough space for the table, I would render it on the page. If not, I would issue a page break and render it on the next page.
Is there a feature to find out the current position on the page after rendering the flow content?
You can force a page break by calling PdfFlowDocument.StartNewPage.
Size information for flow content is not available in the public API, you cannot test in your code if a content object fits the current available space.
We'll support this in the next release.
Create a table with a single row and cell. For the cell use a PdfFlowTableCompositeCell. It has a property Content which is a collection of flow content objects. On the row set EnableRowSplit = false.
var table = new PdfFlowTableContent(1);
//column width in %
table.Columns[0].Width = 100;
var row = table.Rows.Add();
row.EnableRowSplit = false;
var cell = new PdfFlowTableCompositeCell();
//text
cell.Content.Add(new PdfFlowTextContent(new PdfFormattedContent(KswModuleTranslator.PdfFaultReportStationAssuranceText)));
//image
var image = new PdfPngImage(new MemoryStream(signatureData.Signature));
var imgDings = new PdfFlowImageContent(image);
cell.Content.Add(imgDings);
//text
cell.Content.Add(new PdfFlowTextContent(new PdfFormattedContent(signatureInfo.SigneeName)));
row.Cells.Add(cell);
document.AddContent(table);
I have a DocumentContent (AvalonDock) which contains a textEditor. I want to add a toolbar to it at runtime. To do this I need to add a GridDefinition so that the first row has a fixed height (for the toolbar) and the rest of the document content should be filled by the texteditor.
I created a new Grid and added a row definition to it and added the child to it but I don't know how to attach this to the DocumentContent. I am not even sure if it is the right way to add the toolbar. Any suggestions ?
Grid grid = new Grid();
RowDefinition rowDefinition1 = new RowDefinition();
rowDefinition1.Height = new GridLength(32);
grid.RowDefinitions.Insert(0, rowDefinition1);
grid.Children.Insert(0, new IsaDocToolbar());
PS: I forgot to mention that I use AvalonDock 1.3
Why are you doing this in code and not using XAML?
Here is the basic idea/concept using MVVM in XAML
Document content should be a grid with 2 rows
1st row for toolbar
2nd row for text editor
Visibility of the first row can be controlled using binding to a Boolean property and by using BoolToVisibilityConverter.
Hope this helps. I have been doing something similar (not on the document content) for the application. You can checkout my Wide project for a similar concept for toolbars for the window.
I've used this control before and it was very straight forward. I have a data grid view which is bound to a data source. I add a binding navigator control to the form and set it to use the same binding source as the data grid view. I add a text box, which I use to filter the results that appear in the data grid view, and modify the navigator to remove the add and delete items, so all it contains is the navigation buttons an the text box. Everything appears fine until I select a row in the grid...while the row number in the navigator is correct, there is a big red "X" that spans the entire navigation bar, which spans the entire top of the form. I've included a snapshot here:
I get no warnings or exceptions, and have the debugger set to break on any exception thrown. I feel like I am missing something obvious, but it continues to "work", in that the filter works properly and the row number is always correct. Any advice for helping fix this would be greatly appreciated. The data grid view selection change does modify the contents of the form (other controls on the form) but that all works perfectly.
As far as example code, both the data grid view and the binding navigator use a sql view which was added as a data source.
this.dgvSerial.DataSource = this.vwSerialBindingSource;
this.bindingNavigator1.BindingSource = this.vwSerialBindingSource;
I then set the filter for the binding source to be on the text box that resides in the binding navigator:
vwSerialBindingSource.Filter = string.Format("ProductName LIKE '%{0}%' OR LabelProductName LIKE '%{0}%' OR SerialNumber LIKE '%{0}%'", tb.Text);
I do also add a "search button", with an image which is loaded as an embedded resource.
// setup the search button, the image is
// an embedded resource
bindingNavigator1.ImageList = new ImageList();
Assembly _assembly = Assembly.GetExecutingAssembly();
Stream _imageStream = _assembly.GetManifestResourceStream("SNReprint.search.png");
Image currentImage = Image.FromStream(_imageStream);
ToolStripButton searchButton = new ToolStripButton();
searchButton.Image = currentImage;
searchButton.Text = "Search";
searchButton.Font = new Font(searchButton.Font, FontStyle.Bold);
searchButton.BackColor = Color.Lavender;
// Add the button to the toolstrip
bindingNavigator1.Items.Add(searchButton);
There are a bunch of other controls on the form which are bound to columns in the view which are not affected.
I'm not sure what other code I should provide, so much of it is designer generated, and every other aspect of the application works perfectly. Since this problem doesn't appear until the data grid view selection changed event is raised, I have to assume that I'm doing something in this event handler to cause the binding navigator to render incorrectly.
IF there is anything else specific that I can provide that might shed some light on the problem I am more than happy to post it...
I am dynamically creating several dropdown list on the selection changed event of a main (static) dropdown list. These are created in The TableCell of default Table. When submit button is clicked I need to load a new page with selected values of dropdown as parameters. Basically I need to get the dropdown results in the second page.
This is how dropboxes are created:
while (reader.Read())
{
pcID = int.Parse(reader["fk_pcID"].ToString());
pcDesc = GetpcDescription(pcID);
List<Product> prodList = GetProductsBypcID(pcID);
DropDownList ddList = new DropDownList();
ddList.ID = "ddlPC" + pcID;
foreach(Product prod in prodList)
{
ddList.Items.Add(new ListItem(prod.ProductName, prod.ProductID.ToString()));
}
TableCell cell1 = new TableCell();
cell1.Text = pcDesc;
TableCell cell2 = new TableCell();
cell2.Controls.Add(ddList);
TableRow row = new TableRow();
row.Cells.Add(cell1);
row.Cells.Add(cell2);
table.Rows.Add(row);
}
EDIT: The above code runs at the selection changed event of a dropdown which is set to runat server. But dynamically created dropdowns are not set to run at server
Are these drop-down boxes runat="server"? Meaning: did you created them programmaticly via a .net post-back event through the code behind? If so, just get the selected value the same as you would with any other control, and then pass it through a query string or a cookie.
Are these standard html drop-down lists? Good luck reading them from a code-behind. That gets you all tangled up in the viewstate, and while technically possible, is realistically not feasible.
If the second option is the case, it might be a much better option to have your button target a JavaScript function that gets the selected values and then passes them via querystring. Then on the other page you can read the querystrings from the code-behind, or on the client-side.
This sounds like a good candidate for the DynamicControlsPlaceholder. It will preserve your dynamic controls automatically, without requiring any additional code on the page. If you need to create the controls OnSelectedIndexChanged, I think this might be the simplest solution.
It's a free component, and you can download it here.
http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx
I have a basic PDF file that I has 5 different blank content areas that I want to use iTextSharp to write text too. The problem is I'm not sure the best way to accomplish this. I have attempted to use ColumnText to accomplish this, but I cannot seem to add multiple ColumnText objects.
ColumnText tagColumn = new ColumnText(pdfContentByte);
tagColumn.SetSimpleColumn(460, 100, 620, 160);
string[] tagColors = bt.DealerTagColor.Split('|');
Font tagFont = FontFactory.GetFont(bt.DealerTagFont, bt.DealerTagSize, Font.NORMAL, new BaseColor(int.Parse(tagColors[0]), int.Parse(tagColors[1]), int.Parse(tagColors[2])));
Paragraph p = new Paragraph(dto.Tag, tagFont);
p.Leading = bt.DealerTagSize;
tagColumn.AddElement(p);
tagColumn.Go();
What I like about the ColumnText is it allows me to essential define a heigth/width, and position of the text area.
Any thoughts on how I can accomplish this with or without using ColumnText? I just need to have control of the font/fontsize/font color/leading/and width of the area which will allow the text to wrap.
The easiest way would be to create and use form fields on your template PDF. This way you can reference a form field by name and set its value with a simple function call.
This article helped me:
Fill in PDF Form Fields using the Open Source iTextSharp Dynamic Link Library
EDIT: PdfPTables?
If your ColumnTexts are tabularly arranged consider using a PdfPTable. I've used PdfPTables to fill rows of data in forms generated from a blank template form. You need to figure out the x-coordinate of each of your columns and use these values when adding PdfPCells to your table, but it does work. I've never had to set an upper limit to the height of a PdfPCell but I image you can do it.
Check this page for more on PdfPTables.