Parse text from html website using webbrowser? - c#

I want to create a form that acceses a ticket management system website in order to show me in a windows form application, in some textboxes, info like Created by:, Ticket Title, Created at, and so on.
I tried to set a filter to start from a certain line:
var ticketLines = codes.Where(m => m.StartsWith("<TD style=\"WIDTH: 65px; HEIGHT: 22px; LEFT: 110px\" class=hb-table-cell>"));
after generating the html:
var codes = this.webBrowser1.Document.GetElementById("gridBox").InnerHtml.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(m => m.Trim()).ToList();
For this, i have created a list in which i will ad certain info`s i need:
List<string> ticketTitles = new List<string>();
foreach (string line in ticketLines)
{
//select the line from which you want to start scrapping
int y = codes.IndexOf(line);
//ticket title
ticketTitles.Add(codes[y + 1].Substring(codes[y + 1].IndexOf(">") + 1, codes[y + 1].Length - codes[y + 1].IndexOf(">") - 6));
//created at
ticketTitles.Add(codes[y+2].Substring(codes[y+2].IndexOf(">")+1, codes[y+2].Length - codes[y+2].IndexOf(">") - 6 ));
}
in my form i have a 'login' button and a 'generate' button. The generate button activates the page by entering the specific ticket id.
My progress until now is the creation of the automatic login button, without this one you cannot enter the website at a certain ticket number.
How can I show my elements in a textbox? can someone explain to me the process?
Someone tried to help me and saved into a txt all the code in this form:
<DIV style="WIDTH: 416px; HEIGHT: 134px" class=hb-ui-grid>
<DIV style="WIDTH: 416px; HEIGHT: 23px" class=hb-ui-grid-header-outbox>
<DIV style="WIDTH: 19px; HEIGHT: 23px" class="goog-inline-block hb-ui-grid-header-check"><SPAN aria-checked=false class="goog-checkbox goog-checkbox-unchecked" title="Select all tickets" role=checkbox tabIndex=0 yH="checkbox" unselectable="on" closure_uid_7r0z52="58"></SPAN></DIV>
<DIV hideFocus style="WIDTH: 376px; HEIGHT: 23px" class="hb-ui-grid-header hb-ui-grid-header-horizontal goog-inline-block" tabIndex=0 unselectable="on" closure_uid_7r0z52="56">
<TABLE style="WIDTH: 2095px" class=hb-ui-grid-header-content unselectable="on" aH="0">
<TBODY unselectable="on">
<TR unselectable="on"><TD style="TEXT-ALIGN: center; WIDTH: 25px; HEIGHT: 23px" id=:1i class=hb-ui-grid-column title=History unselectable="on" model="H">H</TD><TD style="TEXT-ALIGN: center; WIDTH: 25px; HEIGHT: 23px" id=:1j class=hb-ui-grid-column title=Attachments unselectable="on" model="A">A</TD><TD style="TEXT-ALIGN: center; WIDTH: 60px; HEIGHT: 23px" id=:1k class=hb-ui-grid-column title=Clone unselectable="on" model="C">C</TD><TD style="WIDTH: 65px; HEIGHT: 23px" id=:1l class=hb-ui-grid-column title="Ticket ID" unselectable="on" model="1">Ticket ID</TD><TD style="WIDTH: 542px; HEIGHT: 23px" id=:1m class=hb-ui-grid-column title=Title unselectable="on" model="109">Title</TD><TD style="WIDTH: 95px; HEIGHT: 23px" id=:1n class=hb-ui-grid-column title="Reported on" unselectable="on" model="115">Reported on</TD><TD style="WIDTH: 84px; HEIGHT: 23px" id=:1o class=hb-ui-grid-column title="Detected on" unselectable="on" model="118">Detected on</TD><TD style="WIDTH: 132px; HEIGHT: 23px" id=:1p class=hb-ui-grid-column title="Detected by" unselectable="on" model="119">Detected by</TD><TD style="WIDTH: 118px; HEIGHT: 23px" id=:1q class=hb-ui-grid-column title="System SW-Rev." unselectable="on" model="129">System SW-Rev.</TD><TD style="WIDTH: 126px; HEIGHT: 23px" id=:1r class=hb-ui-grid-column title="Integrated in version" unselectable="on" model="404">Integrated in version</TD><TD style="WIDTH: 16px; HEIGHT: 23px" id=:1s class=hb-ui-grid-column title="Tested in version" unselectable="on" model="507">Tested in version</TD><TD style="WIDTH: 31px; HEIGHT: 23px" id=:1t class=hb-ui-grid-column title=Result unselectable="on" model="504">Result</TD><TD style="WIDTH: 162px; HEIGHT: 23px" id=:1u class=hb-ui-grid-column title="Last change by user" unselectable="on" model="51">Last change by user</TD><TD style="WIDTH: 73px; HEIGHT: 23px" id=:1v class=hb-ui-grid-column title="Ticket state" unselectable="on" model="53">Ticket state</TD><TD style="WIDTH: 102px; HEIGHT: 23px" id=:1w class=hb-ui-grid-column title="Ticket owner" unselectable="on" model="76">Ticket owner</TD><TD style="WIDTH: 99px; HEIGHT: 23px" id=:1x class=hb-ui-grid-column title="Ticket step" unselectable="on" model="55"><SPAN class=hb-ui-grid-sort unselectable="on">▲</SPAN>Ticket step</TD><TD style="WIDTH: 86px; HEIGHT: 23px" id=:1y class=hb-ui-grid-column title="Last change date" unselectable="on" model="52">Last change date</TD><TD style="WIDTH: 64px; HEIGHT: 23px" id=:1z class=hb-ui-grid-column title=Priority unselectable="on" model="215">Priority</TD><TD style="WIDTH: 95px; HEIGHT: 23px" id=:20 class=hb-ui-grid-column title="Sequence of Activity" unselectable="on" model="68">Sequence of Activity</TD></TR></TBODY></TABLE></DIV>
<DIV aria-haspopup=true style="DISPLAY: none" class="goog-inline-block hb-grid-menu-button" title="Overview options" role=button aria-activedescendant="" yH="button" unselectable="on" closure_uid_7r0z52="60">
<DIV class="goog-inline-block hb-grid-menu-button-outer-box" unselectable="on">
<DIV class="goog-inline-block hb-grid-menu-button-inner-box" unselectable="on">
<DIV class="goog-inline-block hb-grid-menu-button-caption" unselectable="on"></DIV>
<DIV class="goog-inline-block hb-grid-menu-button-dropdown" unselectable="on"> </DIV></DIV></DIV></DIV></DIV>
<DIV style="WIDTH: 416px; HEIGHT: 82px" class=hb-ui-grid-scrollarea unselectable="on" closure_uid_7r0z52="71">
<DIV style="WIDTH: 20px; HEIGHT: 64px" class=hb-ui-grid-pane unselectable="on">
<TABLE style="LINE-HEIGHT: 23px; BORDER-SPACING: 0; WIDTH: 0px; BORDER-COLLAPSE: separate; TABLE-LAYOUT: fixed; OVERFLOW: hidden; hasLayout: -1" cellSpacing=0>
<TBODY>
<TR style="LINE-HEIGHT: 22px; WIDTH: 100%" class=hb-ui-grid-row>
<TD style="WIDTH: 15px; HEIGHT: 22px; LEFT: 0px" class=hb-table-cell><SPAN style="-webkit-user-select: none" class=hb-table-cell-check-box></SPAN></TD></TR>
<TR style="LINE-HEIGHT: 22px; WIDTH: 100%" class=hb-ui-grid-row>
<TD style="WIDTH: 15px; HEIGHT: 22px; LEFT: 0px" class=hb-table-cell><SPAN style="-webkit-user-select: none" class=hb-table-cell-check-box></SPAN></TD></TR>
<TR style="LINE-HEIGHT: 22px; WIDTH: 100%" class=hb-ui-grid-row>
<TD style="WIDTH: 15px; HEIGHT: 22px; LEFT: 0px" class=hb-table-cell><SPAN style="-webkit-user-select: none" class=hb-table-cell-check-box></SPAN></TD></TR></TBODY></TABLE></DIV>
<DIV style="WIDTH: 378px; HEIGHT: 64px" class=hb-ui-grid-pane unselectable="on" closure_uid_7r0z52="66">
<TABLE style="LINE-HEIGHT: 23px; BORDER-SPACING: 0; WIDTH: 0px; BORDER-COLLAPSE: separate; TABLE-LAYOUT: fixed; OVERFLOW: hidden; hasLayout: -1" cellSpacing=0>
<TBODY>
<TR style="LINE-HEIGHT: 22px; WIDTH: 100%" class=hb-ui-grid-row>
<TD style="WIDTH: 25px; HEIGHT: 22px; LEFT: 0px" class=hb-table-cell>
<DIV class=hb-ui-calendar></DIV></TD>
<TD style="WIDTH: 25px; HEIGHT: 22px; LEFT: 25px" class=hb-table-cell>
<DIV class=hb-ui-attachment></DIV></TD>
<TD style="WIDTH: 60px; HEIGHT: 22px; LEFT: 50px" class=hb-table-cell> </TD>
<TD style="WIDTH: 65px; HEIGHT: 22px; LEFT: 110px" class=hb-table-cell>1797443</TD>
<TD style="WIDTH: 542px; HEIGHT: 22px; LEFT: 175px" class=hb-table-cell>[MAP]Unexisting street through Ta Phuk river</TD>
<TD style="WIDTH: 95px; HEIGHT: 22px; LEFT: 717px" class=hb-table-cell>2016-01-19</TD>
<TD style="WIDTH: 84px; HEIGHT: 22px; LEFT: 812px" class=hb-table-cell>2016-01-19</TD>
<TD style="WIDTH: 132px; HEIGHT: 22px; LEFT: 896px" class=hb-table-cell>RBalan</TD>
<TD style="WIDTH: 118px; HEIGHT: 22px; LEFT: 1028px" class=hb-table-cell>152153.3.210</TD>
<TD style="WIDTH: 126px; HEIGHT: 22px; LEFT: 1146px" class=hb-table-cell> </TD>
<TD style="WIDTH: 16px; HEIGHT: 22px; LEFT: 1272px" class=hb-table-cell> </TD>
<TD style="WIDTH: 31px; HEIGHT: 22px; LEFT: 1288px" class=hb-table-cell> </TD>
<TD style="WIDTH: 162px; HEIGHT: 22px; LEFT: 1319px" class=hb-table-cell>IModoleev</TD>
<TD style="WIDTH: 73px; HEIGHT: 22px; LEFT: 1481px" class=hb-table-cell>Categorized</TD>
<TD style="WIDTH: 102px; HEIGHT: 22px; LEFT: 1554px" class=hb-table-cell>RBalan</TD>
<TD style="WIDTH: 99px; HEIGHT: 22px; LEFT: 1656px" class=hb-table-cell>Concluding</TD>
<TD style="WIDTH: 86px; HEIGHT: 22px; LEFT: 1755px" class=hb-table-cell>2016-01-26</TD>
<TD style="WIDTH: 64px; HEIGHT: 22px; LEFT: 1841px" class=hb-table-cell>C(3)</TD>
<TD style="WIDTH: 95px; HEIGHT: 22px; LEFT: 1905px" class=hb-table-cell> </TD></TR>
<TR style="LINE-HEIGHT: 22px; WIDTH: 100%" class=hb-ui-grid-row>
<TD style="WIDTH: 25px; HEIGHT: 22px; LEFT: 0px" class=hb-table-cell>
<DIV class=hb-ui-calendar></DIV></TD>
<TD style="WIDTH: 25px; HEIGHT: 22px; LEFT: 25px" class=hb-table-cell>
<DIV class=hb-ui-attachment></DIV></TD>
<TD style="WIDTH: 60px; HEIGHT: 22px; LEFT: 50px" class=hb-table-cell> </TD>
<TD style="WIDTH: 65px; HEIGHT: 22px; LEFT: 110px" class=hb-table-cell>1780104</TD>
<TD style="WIDTH: 542px; HEIGHT: 22px; LEFT: 175px" class=hb-table-cell>[DI]Preview map for country list is not refreshing</TD>
<TD style="WIDTH: 95px; HEIGHT: 22px; LEFT: 717px" class=hb-table-cell>2015-12-15</TD>
<TD style="WIDTH: 84px; HEIGHT: 22px; LEFT: 812px" class=hb-table-cell>2015-12-15</TD>
<TD style="WIDTH: 132px; HEIGHT: 22px; LEFT: 896px" class=hb-table-cell>RBalan</TD>
<TD style="WIDTH: 118px; HEIGHT: 22px; LEFT: 1028px" class=hb-table-cell>161153.3.210</TD>
<TD style="WIDTH: 126px; HEIGHT: 22px; LEFT: 1146px" class=hb-table-cell> </TD>
<TD style="WIDTH: 16px; HEIGHT: 22px; LEFT: 1272px" class=hb-table-cell> </TD>
<TD style="WIDTH: 31px; HEIGHT: 22px; LEFT: 1288px" class=hb-table-cell> </TD>
<TD style="WIDTH: 162px; HEIGHT: 22px; LEFT: 1319px" class=hb-table-cell>IModoleev</TD>
<TD style="WIDTH: 73px; HEIGHT: 22px; LEFT: 1481px" class=hb-table-cell>Categorized</TD>
<TD style="WIDTH: 102px; HEIGHT: 22px; LEFT: 1554px" class=hb-table-cell>RBalan</TD>
<TD style="WIDTH: 99px; HEIGHT: 22px; LEFT: 1656px" class=hb-table-cell>Concluding</TD>
<TD style="WIDTH: 86px; HEIGHT: 22px; LEFT: 1755px" class=hb-table-cell>2016-01-26</TD>
<TD style="WIDTH: 64px; HEIGHT: 22px; LEFT: 1841px" class=hb-table-cell>C(3)</TD>
<TD style="WIDTH: 95px; HEIGHT: 22px; LEFT: 1905px" class=hb-table-cell> </TD></TR>
<TR style="LINE-HEIGHT: 22px; WIDTH: 100%" class=hb-ui-grid-row>
<TD style="WIDTH: 25px; HEIGHT: 22px; LEFT: 0px" class=hb-table-cell>
<DIV class=hb-ui-calendar></DIV></TD>
<TD style="WIDTH: 25px; HEIGHT: 22px; LEFT: 25px" class=hb-table-cell>
<DIV class=hb-ui-attachment></DIV></TD>
<TD style="WIDTH: 60px; HEIGHT: 22px; LEFT: 50px" class=hb-table-cell> </TD>
<TD style="WIDTH: 65px; HEIGHT: 22px; LEFT: 110px" class=hb-table-cell>1774770</TD>
<TD style="WIDTH: 542px; HEIGHT: 22px; LEFT: 175px" class=hb-table-cell>Only one street is shown for postcode 0010(Oslo)</TD>
<TD style="WIDTH: 95px; HEIGHT: 22px; LEFT: 717px" class=hb-table-cell>2015-12-08</TD>
<TD style="WIDTH: 84px; HEIGHT: 22px; LEFT: 812px" class=hb-table-cell>2015-12-08</TD>
<TD style="WIDTH: 132px; HEIGHT: 22px; LEFT: 896px" class=hb-table-cell>RBalan</TD>
<TD style="WIDTH: 118px; HEIGHT: 22px; LEFT: 1028px" class=hb-table-cell>101153.3.211</TD>
<TD style="WIDTH: 126px; HEIGHT: 22px; LEFT: 1146px" class=hb-table-cell> </TD>
<TD style="WIDTH: 16px; HEIGHT: 22px; LEFT: 1272px" class=hb-table-cell> </TD>
<TD style="WIDTH: 31px; HEIGHT: 22px; LEFT: 1288px" class=hb-table-cell> </TD>
<TD style="WIDTH: 162px; HEIGHT: 22px; LEFT: 1319px" class=hb-table-cell>IModoleev</TD>
<TD style="WIDTH: 73px; HEIGHT: 22px; LEFT: 1481px" class=hb-table-cell>Categorized</TD>
<TD style="WIDTH: 102px; HEIGHT: 22px; LEFT: 1554px" class=hb-table-cell>RBalan</TD>
<TD style="WIDTH: 99px; HEIGHT: 22px; LEFT: 1656px" class=hb-table-cell>Concluding</TD>
<TD style="WIDTH: 86px; HEIGHT: 22px; LEFT: 1755px" class=hb-table-cell>2016-01-26</TD>
<TD style="WIDTH: 64px; HEIGHT: 22px; LEFT: 1841px" class=hb-table-cell>C(3)</TD>
<TD style="WIDTH: 95px; HEIGHT: 22px; LEFT: 1905px" class=hb-table-cell> </TD></TR></TBODY></TABLE></DIV>
<DIV style="WIDTH: 18px; HEIGHT: 64px; TOP: 0px; LEFT: 398px" class=hb-grid-scroll-vertical unselectable="on" closure_uid_7r0z52="64">
<DIV style="WIDTH: 1px; HEIGHT: 92px; TOP: 0px; LEFT: 0px" unselectable="on"></DIV></DIV>
<DIV style="WIDTH: 378px; HEIGHT: 18px; TOP: 64px; LEFT: 20px" class=hb-grid-scroll-horizontal unselectable="on" closure_uid_7r0z52="65">
<DIV style="WIDTH: 2095px; HEIGHT: 1px; TOP: 0px; LEFT: 0px" unselectable="on"></DIV></DIV></DIV>
<DIV hideFocus class="goog-toolbar goog-toolbar-horizontal" role=toolbar yH="toolbar" unselectable="on" closure_uid_7r0z52="96">
<DIV id=:2d class="hb-toolbar-label goog-inline-block" tabIndex=0 unselectable="on" closure_uid_7r0z52="72">Mode:</DIV>
<DIV aria-haspopup=true id=:2i class="goog-inline-block goog-toolbar-menu-button" title="" role=button tabIndex=0 yH="button" unselectable="on" closure_uid_7r0z52="74">
<DIV class="goog-inline-block goog-toolbar-menu-button-outer-box" unselectable="on">
<DIV class="goog-inline-block goog-toolbar-menu-button-inner-box" unselectable="on">
<DIV class="goog-inline-block goog-toolbar-menu-button-caption" unselectable="on">All</DIV>
<DIV class="goog-inline-block goog-toolbar-menu-button-dropdown" unselectable="on"> </DIV></DIV></DIV></DIV>
<DIV style="DISPLAY: none" id=:2j class="goog-toolbar-separator goog-inline-block" role=separator yH="separator" unselectable="on"> </DIV>
<DIV style="DISPLAY: none" id=:2k class="goog-inline-block goog-toolbar-button" title="First page" role=button yH="button" unselectable="on" closure_uid_7r0z52="77">
<DIV class="goog-inline-block goog-toolbar-button-outer-box" unselectable="on">
<DIV class="goog-inline-block goog-toolbar-button-inner-box" unselectable="on">
<DIV class="icon hb-grid-first" unselectable="on"></DIV></DIV></DIV></DIV>
<DIV style="DISPLAY: none" id=:2l class="goog-inline-block goog-toolbar-button" title="Previous page" role=button yH="button" unselectable="on" closure_uid_7r0z52="79">
<DIV class="goog-inline-block goog-toolbar-button-outer-box" unselectable="on">
<DIV class="goog-inline-block goog-toolbar-button-inner-box" unselectable="on">
<DIV class="icon hb-grid-left" unselectable="on"></DIV></DIV></DIV></DIV>
<DIV style="DISPLAY: none" id=:2m class="hb-toolbar-label goog-inline-block" unselectable="on" closure_uid_7r0z52="81">Page</DIV><INPUT style="DISPLAY: none" id=:2n class="hb-toolbar-editor goog-inline-block" value=1 maxLength=4 size=2 type=text closure_uid_7r0z52="83">
<DIV style="DISPLAY: none" id=:2o class="hb-toolbar-label goog-inline-block" unselectable="on" closure_uid_7r0z52="85">of 16</DIV>
<DIV style="DISPLAY: none" id=:2p class="goog-inline-block goog-toolbar-button" title="Next page" role=button yH="button" unselectable="on" closure_uid_7r0z52="87">
<DIV class="goog-inline-block goog-toolbar-button-outer-box" unselectable="on">
<DIV class="goog-inline-block goog-toolbar-button-inner-box" unselectable="on">
<DIV class="icon hb-grid-right" unselectable="on"></DIV></DIV></DIV></DIV>
<DIV style="DISPLAY: none" id=:2q class="goog-inline-block goog-toolbar-button" title="Last page" role=button yH="button" unselectable="on" closure_uid_7r0z52="89">
<DIV class="goog-inline-block goog-toolbar-button-outer-box" unselectable="on">
<DIV class="goog-inline-block goog-toolbar-button-inner-box" unselectable="on">
<DIV class="icon hb-grid-last" unselectable="on"></DIV></DIV></DIV></DIV>
<DIV id=:2r class="goog-toolbar-separator goog-inline-block" role=separator yH="separator" unselectable="on"> </DIV>
<DIV id=:2s class="goog-inline-block goog-toolbar-button" title=Refresh role=button tabIndex=0 yH="button" unselectable="on" closure_uid_7r0z52="91">
<DIV class="goog-inline-block goog-toolbar-button-outer-box" unselectable="on">
<DIV class="goog-inline-block goog-toolbar-button-inner-box" unselectable="on">
<DIV class="icon icon hb-grid-refresh" unselectable="on"></DIV></DIV></DIV></DIV>
<DIV id=:2t class="goog-toolbar-separator goog-inline-block" role=separator yH="separator" unselectable="on"> </DIV>
<DIV style="COLOR: black" id=:2u class="hb-toolbar-label goog-inline-block" tabIndex=0 unselectable="on" closure_uid_7r0z52="93">3 tickets found</DIV></DIV></DIV>
My full c# code is here:
using System.Threading;
namespace snippet
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.webBrowser1.Navigate("https://elvis.harman.com/");
while (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
Thread.Sleep(100);
Application.DoEvents();
}
//textBox1.Text= this.webBrowser1.Document.Window.Frames[2].Document.GetElementsByTagName("input").Count.ToString();
this.webBrowser1.Document.Window.Frames[2].Document.GetElementsByTagName("input")[0].InnerText = textBox1.Text;
this.webBrowser1.Document.Window.Frames[2].Document.GetElementsByTagName("input")[1].InnerText = textBox2.Text;
this.webBrowser1.Document.Window.Frames[2].Document.GetElementsByTagName("button")[0].InvokeMember("click");
//MessageBox.Show("Done!");
}
private void button2_Click(object sender, EventArgs e)
{
this.webBrowser1.Navigate("https://elvis.harman.com/cgi-bin/ticket?TID=" + txtID.Text);
Thread.Sleep(2000);
//this.webBrowser1.Navigate("https://elvis.harman.com/cgi-bin/ticket?TID=" + txtID.Text);
//Thread.Sleep(2000);
this.webBrowser1.Update();
//var b = this.webBrowser1.Document.GetElementById("ticketHeader").InnerHtml;
// txtTitle.Text = this.webBrowser1.Document.GetElementById("field_100");
var codes = this.webBrowser1.Document.GetElementById("gridBox").InnerHtml.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(m => m.Trim()).ToList();
//search in code for the line that starts with " "
var ticketLines = codes.Where(m => m.StartsWith("<TD style=\"WIDTH: 65px; HEIGHT: 22px; LEFT: 110px\" class=hb-table-cell>"));
//create list in which will store the text filtered
List<string> ticketTitles = new List<string>();
foreach (string line in ticketLines)
{
//select the line from which you want to start scrapping
int y = codes.IndexOf(line);
//ticket title
ticketTitles.Add(codes[y + 1].Substring(codes[y + 1].IndexOf(">") + 1, codes[y + 1].Length - codes[y + 1].IndexOf(">") - 6));
//created at
ticketTitles.Add(codes[y+2].Substring(codes[y+2].IndexOf(">")+1, codes[y+2].Length - codes[y+2].IndexOf(">") - 6 ));
}
//int x = 1;
}
How can I reproduce this to reach to this code. it seems that is different than using inspect element in Chrome? Or how can I proceed further in this?
Thank you!

Related

Style aspx navigationmenu with submenu on hover

This is how my menu looks like:
I tried to change the width of the SUB1 button but failed. SUB2 has the right width but should be on the left. I think I'm missing a CSS class for the submenu. The menu should look like this:
I tried around changing the ul li and a in the site.css but can't reach the goal.
aspx:
<asp:Menu ID="StartMenu" runat="server" CssClass="menuStart" EnableViewState="false"
IncludeStyleBlock="true" Orientation="Horizontal" RenderingMode="List"
StaticEnableDefaultPopOutImage="false" StaticSelectedStyle-BackColor="#b90276">
<StaticMenuItemStyle HorizontalPadding="20" VerticalPadding="10" />
<Items>
<asp:MenuItem Text="ITEM1" >
<asp:MenuItem Text="SUB1"></asp:MenuItem>
<asp:MenuItem Text="SUB2"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="ITEM2"></asp:MenuItem>
</Items>
<StaticSelectedStyle BackColor="#B90276"></StaticSelectedStyle>
</asp:Menu>
div.menuStart {
padding: 16px 16px 16px 16px;
}
div.menuStart ul {
background-color: #cccccc;
}
div.menuStart a,
a:visited {
background-color: #7d8790;
border-top: 4px #ffffff solid;
border-right: 4px #ffffff solid;
border-bottom: 4px #ffffff solid;
border-left: 4px #ffffff solid;
color: #ffffff;
display: normal;
line-height: 1.35em;
padding: 4px 20px;
text-decoration: none;
white-space: nowrap;
font: "Verdana";
font-size: 20px;
}
div.menuStart li~li {
padding-left: 100px;
}
div.menuStart ul li a:hover {
background-color: #b90276;
color: #ffffff;
text-decoration: none;
}
div.menuStart ul li a:active {
background-color: #b90276;
color: #ffffff;
text-decoration: none;
}
<div class="menuStart" id="MainContent_StartMenu" style="float: left;">
<ul class="level1 static" tabindex="0" role="menubar" style="position: relative; width: auto; float: left;">
<li class="has-popup static" aria-haspopup="MainContent_StartMenu:submenu:21" role="menuitem" style="position: relative; float: left;"><a class="level1 static" href="#" onclick="__doPostBack('ctl00$MainContent$StartMenu','ITEM1')" tabindex="-1">ITEM1</a>
<ul class="level2 dynamic" id="MainContent_StartMenu:submenu:21" style="display: none; position: absolute; top: 100%; left: 0px;">
<li role="menuitem" class="dynamic" style="position: relative;"><a class="level2 dynamic" href="#" onclick="__doPostBack('ctl00$MainContent$StartMenu','ITEM1\\SUB1')" tabindex="-1">SUB1</a></li>
<li role="menuitem" class="dynamic" style="position: relative;"><a class="level2 dynamic" href="#" onclick="__doPostBack('ctl00$MainContent$StartMenu','ITEM1\\SUB2')" tabindex="-1">SUB2</a></li>
</ul>
</li>
<li role="menuitem" class="static" style="position: relative; float: left;"><a class="level1 static" href="#" onclick="__doPostBack('ctl00$MainContent$StartMenu','ITEM2')" tabindex="-1">ITEM2</a></li>
<li class="has-popup static" aria-haspopup="MainContent_StartMenu:submenu:26" role="menuitem" style="position: relative; float: left;"><a class="level1 static" href="#" onclick="__doPostBack('ctl00$MainContent$StartMenu','ITEM3')" tabindex="-1">ITEM3</a>
<ul class="level2 dynamic" id="MainContent_StartMenu:submenu:26" style="display: none; position: absolute; top: 100%; left: 0px;">
<li role="menuitem" class="dynamic" style="position: relative;"><a class="level2 dynamic" href="#" onclick="__doPostBack('ctl00$MainContent$StartMenu','ITEM3\\SUB1')" tabindex="-1">SUB1</a></li>
<li role="menuitem" class="dynamic" style="position: relative;"><a class="level2 dynamic" href="#" onclick="__doPostBack('ctl00$MainContent$StartMenu','ITEM3\\SUB2')" tabindex="-1">SUB2</a></li>
</ul>
</li>
</ul>
</div>

Only one UpdatePanel triggered by JavaScript updated the content

I have two update panel which I triggered in javascript. After I run the code, only the second Panel's content is updated. Here is MyCode.
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="display: normal">
<asp:Button ID="PaperContent_Button1" runat="server" Text="Update box Panel" OnClick="LoadPaperData" />
</div>
<div class="ibox-content_v2" style="height: 150px;">
<div style="display: inline; height: 100px; float: right; max-width: 70%; min-width: 165px; width: 70%">
<asp:Label ID="uiBox1Value" runat="server" Style="font-size: 30px; font-weight: 600; color: #002467" />
<asp:Label ID="uiBox1Unit" runat="server" Style="font-size: 13px; font-weight: 600; color: #002467" />
</div>
<div id="uiBox1TargetPanel" runat="server" onmouseover="document.getElementById('ContentPlaceHolder1_uiBox1Popup').style.visibility = 'visible';" onmouseout="document.getElementById('ContentPlaceHolder1_uiBox1Popup').style.visibility = 'hidden';">
<div id="uiBox1Popup" runat="server" style="float: left; position: relative; top: -50px; visibility: hidden; width: 100%; height: 40px; text-align: center; border-width: 1px; border-style: solid; border-color: #D2D9E3; background-color: #F2F3F6; font-size: 13px; font-weight: 600; padding-top: 10px;">
<asp:Label ID="uiBox1TargetLabel" runat="server" />:
<asp:Image ID="uiBox1TargetUpOrDownImage" runat="server" Width="6" Height="9" Style="margin-right: 5px; margin-bottom: 4px;" ImageUrl="images/ico_arrow_xs_r_up.png" />
<asp:Label ID="uiBox1TargetValue" runat="server" />%
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div style="display: normal">
<asp:Button ID="WaterContent_Button1" runat="server" Text="Update box Panel" OnClick="LoadWaterData" />
</div>
<div class="ibox-content_v2" style="height: 150px;">
<div style="display: inline; height: 100px; float: right; max-width: 70%; min-width: 165px; width: 70%">
<asp:Label ID="uiBox2Value" runat="server" Style="font-size: 30px; font-weight: 600; color: #002467" />
<asp:Label ID="uiBox2Unit" runat="server" Style="font-size: 13px; font-weight: 600; color: #002467" />
</div>
<div id="uiBox2TargetPanel" runat="server" onmouseover="document.getElementById('ContentPlaceHolder1_uiBox2Popup').style.visibility = 'visible';" onmouseout="document.getElementById('ContentPlaceHolder1_uiBox2Popup').style.visibility = 'hidden';">
<div id="uiBox2Popup" runat="server" style="float: left; position: relative; top: -50px; visibility: hidden; width: 100%; height: 40px; text-align: center; border-width: 1px; border-style: solid; border-color: #D2D9E3; background-color: #F2F3F6; font-size: 13px; font-weight: 600; padding-top: 10px;">
<asp:Label ID="uiBox2TargetLabel" runat="server" />:
<asp:Image ID="uiBox2TargetUpOrDownImage" runat="server" Width="6" Height="9" Style="margin-right: 5px; margin-bottom: 4px;" ImageUrl="images/ico_arrow_xs_r_up.png" />
<asp:Label ID="uiBox2TargetValue" runat="server" />%
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
I triggered code behind using javascript, however, after run the code, only the second is updated.
<script>
$(document).ready(function () {
$("#ContentPlaceHolder1_PaperContent_Button1").click();
$("#ContentPlaceHolder1_WaterContent_Button1").click();
});
</script>
But I want both UpdatePanel be updated. What can I do to enable both updatepanel be updated?
If you can, change the UpdateMode of the 2nd panel:
UpdateMode="Always"
then remove the 2nd .click() in the javascript. The 2nd panel should update when the first panel updates (when a postback happens).
If you can't use Always, you can add an OnLoad event to the 2nd panel and move any code you have to that event. When a postback happens the 2nd panel will always reload and the code will fire.
Hth.

Complete border on page of print of Web page

I am having a web page and on button of print.
when i click on that button i am trying to print that web page
Here is my button
<asp:ImageButton ID="ImageButton1" runat="server" ToolTip="Cancel" AlternateText="Print"
ImageUrl="~/admin/images/print_btn.png" OnClientClick='javascript:window.print();' />
My web page contains more than 3 print page. I have set a border on Media Print.
but it is not working properly.
there is only one bottom border that is at the last page.
I need borders on each page of print.
Is it possible using javascript or jquery?
if it is possible using c# then also let me know
here is my code
<style type="text/css">
#media print
{
.TblBorder
{
border-collapse: collapse;
border: solid 1px black;
}
.TblBorder td
{
border: solid 1px black;
}
.TblBorder th
{
border: solid 1px black;
}
}
</style>
<table width="100%" cellpadding="8" cellspacing="2">
<tr class="printable">
<td colspan="3" align="center" style="color: Black; font-family: Calibri; font-size: 18px;
font-weight: bold">
<asp:Label ID="lblHeading" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr class="non-printable" visible="false" runat="server" id="trPrintPlantandMachinery">
<td colspan="3" align="left">
<asp:LinkButton ID="lnkbtnPlantMachinery" runat="server" CssClass="left_panel" Text="<b>1. Download & Print Plant & Machinery List</b>"
OnClick="lnkbtnPlantMachinery_Click" Font-Underline="true"></asp:LinkButton>
</td>
</tr>
<tr class="printable">
<td style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;"
width="49%">
Date of Visit the Enterprise
</td>
<td style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;"
width="1%">
:
</td>
<td width="50%" style="font-family: calibri; font-size: 15px; font-weight: bold;">
<asp:Label ID="txtDateofVisit" runat="server"></asp:Label>
</td>
</tr>
<tr class="printable">
<td style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;"
width="49%">
Application Number
</td>
<td style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;"
width="1%">
:
</td>
<td width="50%" style="font-family: calibri; font-size: 15px; font-weight: bold;">
<asp:Label ID="lblApplicationNo" runat="server" Text="-"></asp:Label>
</td>
</tr>
<tr class="printable">
<td width="49%" style="font-family: calibri; font-size: 14px; font-weight: bold;
color: Black;">
Scheme Name
</td>
<td width="1%" style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;">
:
</td>
<td width="50%" style="font-family: calibri; font-size: 15px; font-weight: bold;">
<asp:Label ID="lblSchemeName" runat="server"></asp:Label>
</td>
</tr>
<tr class="printable">
<td width="49%" style="font-family: calibri; font-size: 14px; font-weight: bold;
color: Black;">
Name of Enterprise
</td>
<td width="1%" style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;">
:
</td>
<td width="50%" style="font-family: calibri; font-size: 15px; font-weight: bold;">
<asp:Label ID="lblUnitName" runat="server" Text="-"></asp:Label>
</td>
</tr>
<tr class="printable">
<td width="49%" style="font-family: calibri; font-size: 14px; font-weight: bold;
color: Black;">
Enterprise Address
</td>
<td width="1%" style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;">
:
</td>
<td width="50%" style="font-family: calibri; font-size: 15px; font-weight: bold;">
<asp:Label ID="lblIndustryUnitAddress" runat="server" Text="-"></asp:Label>
</td>
</tr>
</table>
<table width="100%" cellpadding="5" cellspacing="2" border="0">
<tr>
<td style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;"
width="49%">
Constitution of The Unit
</td>
<td style="font-family: calibri; font-size: 14px; font-weight: bold; color: Black;"
width="1%">
:
</td>
<td width="50%" style="font-family: calibri; font-size: 15px; font-weight: bold;">
<asp:Label ID="lblConstitutionUnit" runat="server" Text="-"></asp:Label>
</td>
</tr>
<tr>
<td style="font-family: calibri; font-size: 16px; font-weight: bold; color: Black"
colspan="3">
<u>Entrepreneur's Profile Details</u>
</td>
</tr>
</table>

How to Reopen pure CSS3 modal dialog

I have following Modal Dialog (popup) using only CSS3 in my asp page for user registration:
HTML :
<%-- Modal PopUp starts here--%>
<div id="openModal" class="modalDialog">
<div> X
<table style="width:100%;">
<tr>
<td style="text-align: center; width: 100%;"></td>
</tr>
<tr>
<td style="text-align: center; width: 100%;">
<asp:Label ID="lblErrorMSG2" runat="server" Font-Bold="True" ForeColor="#FF3300" Text="Email ID Already Taken " Visible="False"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%;">
<input id="txtCustFName" name="txtCustFName" type="text" required placeholder="Enter Your First Name" style="width: 80%" />
</td>
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%;">
<input id="txtCustLName" name="txtCustLName" type="text" required placeholder="Enter Your Last Name" style="width: 80%" />
</td>
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%;">
<input id="txtCustREmail" name="txtCustREmail" type="email" required placeholder="Enter Valid Email ID" style="width: 80%" />
</td>
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%;">
<input id="txtCustRPwd" name="txtCustRPwd" type="password" required placeholder="Enter Password" style="width: 80%" />
</td>
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%;">
<input id="txtCustRePwd" name="txtCustRePwd" type="password" required placeholder="ReType Password" style="width: 80%" />
</td>
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%;">
<input id="txtCustPh" name="txtCustPh" type="number" size="10" min="10" max="10" required placeholder="Enter Valid Mobile No" style="width: 80%" />
</td>
</td>
</tr>
<tr>
<td class="style1" style="text-align: center; width: 100%;" onclick="btnSignUp()">
<asp:Button ID="btnSingUp" runat="server" onclick="signUp" Text="Login" />
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%;"> </td>
</tr>
</table>
</div>
</div>
<%--Modal PopUp Ends Here--%>
CSS :
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;}
.close:hover { background: #00d9ff;
}
In my asp page I've following anchor tag which is used to display the popup:
Register
Now the problem is:
As this is registration form, I want server side validation of existing email id .
If user entered email id already exist in DB I want to reopen the above modal dialog with an error message Email ID already exist.
I m not able to reopen that dialog box.
Is there any way to do this using js?
Plz help me.
The tutorial for modal dialog is on site:
click here
For visualizing modal dialog:
click here
Thanx in advance.
for server side validation I suggest you to use javascript web method for this. By using this web method your popup didn't close while page check server side validation.....
Change the :target to also accept a class:
.modalDialog:target, .modalDialog.target {
opacity:1;
pointer-events: auto;
}
And then when you find out the email is invalid, you can just do:
$('.modalDialog').addClass('target')
or the non-jquery equivalent.

Implement a html-widget (form) into an asp-site

I try to implement the following widget in my asp.net-site:
<div style="width: 175px; margin: 0px; padding: 0px; text-align: right; background-color:#FFFFFF;">
<img src="http://fahrplan.sbb.ch/img/igm-sbblogo.gif" width="110" height="18" alt="SBB|CFF|FFS" />
<h1 style="width:175px; background-color: #DDDDDD; color: #000000; font-family: Arial, Helvetica, sans-serif; font-size:12px; font-weight: bold; padding: 2px 0px; margin: 0; height: 15px; text-align: left;clear:both;"> Fahrplan</h1>
<div style="width: 100%; background-color: #F8F8F8; margin: 0; padding: 0px;" summary="Layout">
<form action="http://fahrplan.sbb.ch/bin/query.exe/dn?externalCall=yes&DCSext.wt_fp_request=partner_mini" name="formular" method="post" style="display:inline" target="_blank">
<input type="hidden" name="queryPageDisplayed" value="yes">
<table cellspacing="0" cellpadding="4" style="width: 170px; margin: 2px;" class="ig">
<tr>
<th nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; font-weight:bold; width: 55px;">
Von:
</th>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;" colspan="2">
<input type="hidden" name="REQ0JourneyStopsSID" value="A=1#O=Stettbach, Bahnhof#X=8596132#Y=47397270#U=85#L=008591065#B=1#p=1338878028#">
<span style="font-weight:bold;">Stettbach, Bahnhof</span>
</td>
</tr>
<tr>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<select name="REQ0JourneyStopsZA" style="background-color:#fff; border: 1px solid #7F9DB9; color: #000; width: 60px; font-size:11px; margin:0px 0px;">
<option selected="selected" value="7">Nach:</option>
<option value="1">Bhf./Haltest.</option>
<option value="2">Ort, Strasse Nr.</option>
<option value="4">Sehenswürdigkeit</option>
</select>
</td>
<td style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;" colspan="2">
<input type="text" name="REQ0JourneyStopsZG" value="" size="16" style="background-color:#fff; border: 1px solid #7F9DB9; color: #000; width: 100px; height: 18px; font-size: 11px" accesskey="t" tabindex="2">
<input type="hidden" name="REQ0JourneyStopsZID">
</td>
</tr>
<tr>
<th nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; font-weight:bold; width: 55px;">
Datum:
</th>
<td nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<b>08.06.12</b>
<input type="hidden" name="REQ0JourneyDate" value="08.06.12" accesskey="d">
</td>
</tr>
<tr>
<th nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; font-weight:bold; width: 55px;">
Zeit:
</th>
<td nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<input type="text" name="REQ0JourneyTime" value="11:02" size="5" maxlength="5" style="background-color:#fff; border: 1px solid #7F9DB9; color: #000; width: 100px; height: 18px; font-size: 11px" accesskey="c" tabindex="4">
</td>
</tr>
<tr>
<th> </th>
<td nowrap="nowrap" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:left; vertical-align:middle; padding:2px 3px 2px 0px;">
<input class="radio" type="radio" name="REQ0HafasSearchForw" value="1" checked style="margin-right:3px;">Abfahrt
<br /><input class="radio" type="radio" name="REQ0HafasSearchForw" value="0" style="margin-right:3px;">Ankunft
</td>
</tr>
<tr>
<td colspan="2" style="text-align:left;">
<input type="hidden" name="start" value="Suchen">
<input type="submit" name="start" value="Verbindung suchen" tabindex="5" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; text-align:center; width:130px; vertical-align: middle; cursor:pointer; -moz-border-radius: 3px 3px 3px 3px; background-color:#EE0000; border:1px solid #B20000; color:#FFFFFF; font-weight:bold; height:auto; line-height:20px; padding:0px 10px; text-decoration:none; white-space:nowrap;">
</td>
</tr>
<tr>
<td colspan="2" style="text-align:left;">
<a style="font-family:Arial,Helvetica,sans-serif; font-size:12px; text-align:left; margin-top:4px; color: #6B7786; text-decoration:none; display:block;" href="http://www.sbb.ch/166" target="_blank" title="Aktuelle Informationen zu Streiks und grösseren Unterbrüchen im Schienenverkehr."><img src="http://fahrplan.sbb.ch/img/one/icon_arrow_right.png" alt="" style="vertical-align:top; padding-right:2px; border:none;" />Bahnverkehrsinformation</a>
</td>
</tr>
</table>
</form>
</div>
</div>
<script language="JavaScript1.2" type="text/javascript">
/* <![CDATA[ */
var time=new Date();
var hour = time.getHours(); hour=(hour<10)? '0'+hour:hour;
var minute = time.getMinutes();minute=(minute<10)? '0'+minute:minute;
var travelTime = hour+':'+minute;
document.formular.REQ0JourneyTime.value=travelTime;
// /* ]]> */
</script>
Source of the code: http://fahrplan.sbb.ch/bin/help.exe/en?application=INPUTGEN&tpl=inputgen_start
When I create a normal HTML-site the widget works without problems.
But in an asp-site there is a problem with the javascript.
In the line "document.formular.REQ0JourneyTime.value=travelTime;" there comes this error-message:
"JScript runtime error: The property "REQ0JourneyTime" can not be retrieved value: The object is null or undefined."
I think the problem has something to do with the form-tag of the widget ands the post-action, but I doent know, what exactly it is :S
Does somebody know how to fix that issue? Thank you very much!
Michael
You should probably be accessing the form by document.forms.formular or document.forms['formular'], not document.formular.
Also, on the end of the <input ... name="REQ0JourneyTime" ... /> you have > not />.
I think you have nested an HTML form inside your ASPX server-side form tag.
Form tag on ASP.net page
You could try using AJaX within your widget rather than posting back via traditions form.
Read this article too: http://msdn.microsoft.com/en-us/magazine/cc164151.aspx

Categories

Resources