I have just downloaded HTML purifier in order to clean my wysigyg editor inputs but it seems to be stripping out tables.
If I input this text:
<font face="Times New Roman" size="3">
</font><p style="margin: 0in 0in 0pt; line-height: 150%; mso-outline-level: 3;"><span style='color: black; line-height: 150%; font-family: "Arial","sans-serif"; font-size: 12pt; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'>Recruitment methods</span></p><font face="Times New Roman" size="3">
</font><table style="border: currentColor; border-image: none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt;" border="1" cellspacing="0" cellpadding="0"><font face="Times New Roman" size="3">
</font><tbody><tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes;"><font face="Times New Roman" size="3">
</font><td width="37" style="padding: 0in 5.4pt; border: 1pt solid windowtext; border-image: none; width: 27.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt;"><font face="Times New Roman" size="3">
</font><p align="center" style="margin: 0in 0in 0pt; text-align: center; line-height: normal;"><span style='font-family: "Arial","sans-serif"; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'><font size="3">No.</font></span></p><font face="Times New Roman" size="3">
</font></td><font face="Times New Roman" size="3">
</font><td width="180" style="border-width: 1pt 1pt 1pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; border-image: none; width: 134.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"> </td><font face="Times New Roman" size="3">
</font><td width="210" style="border-width: 1pt 1pt 1pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; border-image: none; width: 157.5pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"> </td><font face="Times New Roman" size="3">
</font><td width="211" style="border-width: 1pt 1pt 1pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; border-image: none; width: 2.2in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"> </td><font face="Times New Roman" size="3">
</font></tr><font face="Times New Roman" size="3">
</font><tr style="mso-yfti-irow: 1;"><font face="Times New Roman" size="3">
</font><td width="37" style="border-width: 0px 1pt 1pt; border-style: none solid solid; border-color: rgb(0, 0, 0) windowtext windowtext; padding: 0in 5.4pt; border-image: none; width: 27.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"><font face="Times New Roman" size="3">
</font><p align="center" style="margin: 0in 0in 0pt; text-align: center; line-height: normal;"><span style='font-family: "Arial","sans-serif"; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'><font size="3">1</font></span></p><font face="Times New Roman" size="3">
</font></td><font face="Times New Roman" size="3">
</font><td width="180" style="border-width: 0px 1pt 1pt 0px; border-style: none solid solid none; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; width: 134.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"> </td><font face="Times New Roman" size="3">
</font><td width="210" style="border-width: 0px 1pt 1pt 0px; border-style: none solid solid none; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; width: 157.5pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"> </td><font face="Times New Roman" size="3">
</font><td width="211" style="border-width: 0px 1pt 1pt 0px; border-style: none solid solid none; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; width: 2.2in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"> </td><font face="Times New Roman" size="3">
</font></tr><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font></tbody></table><font face="Times New Roman" size="3">
</font><p align="center" style="margin: 0in 0in 10pt; text-align: center;"><span style='line-height: 115%; font-family: "Arial","sans-serif"; font-size: 12pt; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'> </span></p><font face="Times New Roman" size="3">
</font><p style="margin: 0in 0in 10pt;"><font face="Times New Roman" size="3">
</font><br>
I get this output:
<font face="Times New Roman" size="3">
</font><p style="margin:0in 0in 0pt;line-height:150%;"><span style="color:#000000;line-height:150%;font-family:Arial, 'sans-serif';font-size:12pt;">Recruitment methods</span></p><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><p align="center" style="margin:0in 0in 0pt;text-align:center;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">No.</font></span></p><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><p align="center" style="margin:0in 0in 0pt;text-align:center;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">Method</font></span></p><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><p align="center" style="margin:0in 0in 0pt;text-align:center;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">Strengths</font></span></p><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><p align="center" style="margin:0in 0in 0pt;text-align:center;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">Weaknesses</font></span></p><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><p align="center" style="margin:0in 0in 0pt;text-align:center;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">1</font></span></p><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><p style="margin:0in 0in 0pt;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">Internal recruitment</font></span></p><font face="Times New Roman" size="3">
</font><p style="margin:0in 0in 0pt;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">Promotion</font></span></p><font face="Times New Roman" size="3">
</font><p style="margin:0in 0in 0pt;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3">Lateral transfer</font></span></p><font face="Times New Roman" size="3">
</font><p style="margin:0in 0in 0pt;line-height:normal;"><span style="font-family:Arial, 'sans-serif';"><font size="3"> </font></span></p><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3"> etc...
My setup looks like this:
require_once 'purify/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML.Allowed', 'p,span[style|class],a[href|title],abbr[title],acronym[title],b,strong,blockquote[cite],code,em,i,iframe[src|width|height],img[alt|title|class|src|height|width],h1,h2,h3,h3,ol,ul,li,table[class|style],tr,td,hr');
$purifier = new HTMLPurifier($config);
I only added the HTML.Allowed line in order to try and specifically allow tables, but that didn't work. Does anyone have any idea why it is stripping out tables even though it shouldn't be?
Thanks
It is a bit odd - initially I thought maybe one of the <font> tags (an inline element) were surrounding a block-level element, thus forcing it to get stripped, and the error then cascading up from there, but after running the code through a basic (dumb) HTML formatter, it looks like they're all fairly self-contained.
But turning on Error Collection shows us what's going on. The trouble seems to be that despite being self-contained, HTML Purifier closes the <table> tag once it encounters the first <font>, it doesn't remove the <font> (as one might think):
Notice Line 7, Column 8: <table> started on line 6 auto-closed by <font>
Error Line 10, Column 8: style attribute on <tr> removed
Notice Line 11, Column 12: <tr> started on line 10 auto-closed by <font>
Notice Line 11, Column 12: <tbody> started on line 9 auto-closed by <font>
Warning Line 31, Column 8: Unnecessary </tr> tag removed
Error Line 34, Column 8: style attribute on <tr> removed
Notice Line 35, Column 12: <tr> started on line 34 auto-closed by <font>
Warning Line 55, Column 8: Unnecessary </tr> tag removed
Warning Line 59, Column 8: Unnecessary </tbody> tag removed
Warning Line 60, Column 4: Unnecessary </table> tag removed
Notice End of Document: <p> tag started on line 66 closed by end of document
Warning End of Document: Contents of <div> node reorganized to enforce its content model
That's the output of the demo if you select CollectErrors: Yes and plug in the following HTML:
<font face="Times New Roman" size="3">
</font>
<p style="margin: 0in 0in 0pt; line-height: 150%; mso-outline-level: 3;"><span style='color: black; line-height: 150%; font-family: "Arial","sans-serif"; font-size: 12pt; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'>Recruitment methods</span></p>
<font face="Times New Roman" size="3">
</font>
<table style="border: currentColor; border-image: none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 5.4pt 0in 5.4pt;" border="1" cellspacing="0" cellpadding="0">
<font face="Times New Roman" size="3">
</font>
<tbody>
<tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes;">
<font face="Times New Roman" size="3">
</font>
<td width="37" style="padding: 0in 5.4pt; border: 1pt solid windowtext; border-image: none; width: 27.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt;">
<font face="Times New Roman" size="3">
</font>
<p align="center" style="margin: 0in 0in 0pt; text-align: center; line-height: normal;"><span style='font-family: "Arial","sans-serif"; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'><font size="3">No.</font></span></p>
<font face="Times New Roman" size="3">
</font>
</td>
<font face="Times New Roman" size="3">
</font>
<td width="180" style="border-width: 1pt 1pt 1pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; border-image: none; width: 134.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"> </td>
<font face="Times New Roman" size="3">
</font>
<td width="210" style="border-width: 1pt 1pt 1pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; border-image: none; width: 157.5pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"> </td>
<font face="Times New Roman" size="3">
</font>
<td width="211" style="border-width: 1pt 1pt 1pt 0px; border-style: solid solid solid none; border-color: windowtext windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; border-image: none; width: 2.2in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt;"> </td>
<font face="Times New Roman" size="3">
</font>
</tr>
<font face="Times New Roman" size="3">
</font>
<tr style="mso-yfti-irow: 1;">
<font face="Times New Roman" size="3">
</font>
<td width="37" style="border-width: 0px 1pt 1pt; border-style: none solid solid; border-color: rgb(0, 0, 0) windowtext windowtext; padding: 0in 5.4pt; border-image: none; width: 27.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;">
<font face="Times New Roman" size="3">
</font>
<p align="center" style="margin: 0in 0in 0pt; text-align: center; line-height: normal;"><span style='font-family: "Arial","sans-serif"; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'><font size="3">1</font></span></p>
<font face="Times New Roman" size="3">
</font>
</td>
<font face="Times New Roman" size="3">
</font>
<td width="180" style="border-width: 0px 1pt 1pt 0px; border-style: none solid solid none; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; width: 134.95pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"> </td>
<font face="Times New Roman" size="3">
</font>
<td width="210" style="border-width: 0px 1pt 1pt 0px; border-style: none solid solid none; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; width: 157.5pt; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"> </td>
<font face="Times New Roman" size="3">
</font>
<td width="211" style="border-width: 0px 1pt 1pt 0px; border-style: none solid solid none; border-color: rgb(0, 0, 0) windowtext windowtext rgb(0, 0, 0); padding: 0in 5.4pt; width: 2.2in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt;"> </td>
<font face="Times New Roman" size="3">
</font>
</tr>
<font face="Times New Roman" size="3">
</font><font face="Times New Roman" size="3">
</font>
</tbody>
</table>
<font face="Times New Roman" size="3">
</font>
<p align="center" style="margin: 0in 0in 10pt; text-align: center;"><span style='line-height: 115%; font-family: "Arial","sans-serif"; font-size: 12pt; mso-ascii-theme-font: minor-bidi; mso-hansi-theme-font: minor-bidi; mso-bidi-font-family: Arial; mso-bidi-theme-font: minor-bidi;'> </span></p>
<font face="Times New Roman" size="3">
</font>
<p style="margin: 0in 0in 10pt;"><font face="Times New Roman" size="3">
</font><br>
There's another thread on the HTML Purifier forum that might make this a bit more understandable. Symptoms were described like this:
When I try to purify this code:
<table>
<tr>
<td>
<li>fffff</li>
</td>
</tr>
</table>
I get:
<table>
<tr>
<td>
</td>
</tr>
</table>
fffff
And (my, heh) response back then:
I imagine what's happening is that HTML Purifier is detecting that <li> cannot be opened at that position - but rather than strip the <li> first, it auto-closes the other open tags at that point, resulting (initially) in:
<table>
<tr>
<td>
</td>
</tr>
</table>
<li>fffff</li>
</td>
</tr>
</table>
Then removing extraneous closing tags...
<table>
<tr>
<td>
</td>
</tr>
</table>
<li>fffff</li>
And then stripping the <li>, resulting in what is being observed:
<table>
<tr>
<td>
</td>
</tr>
</table>
fffff
You could try to switch the Lexer to DirectLex and see if that changes the behaviour, but I doubt it - you might be stuck with this behaviour. Give it a whirl, though.
Related
Hi I am a beginner to tailwind css and all i want is a problem that has been occuring to me I want to create a scrollable view with the title headings staying in place and the data below the heading in the table to be scrollable but when I use flex flex-col
the scroll seems to be working but the data seems to contract but as soon as I remove flex flex-col
it comes back to the position but the scroll doesn't work. Can you please say me how do I do it 🙏. I want the title to stay in place but the data should be scrollable.Please note that there is a search bar on top of this table.I want the table to be static also and be seen so top-0 didn't work for me. This is my code 👇.
<div className="mt-5 overflow-x-auto rounded-lg">
<table className=" h-80 w-full text-left text-sm text-gray-400">
<thead className="bg-[#292A33] text-xs uppercase">
<tr className="">
<th className=" px-6 py-3">
nft Name
</th>
<th className=" px-6 py-3">
nft Status
</th>
<th className=" px-6 py-3">
nft Size
</th>
<th className=" px-6 py-3">
nft Type
</th>
<th className=" px-6 py-3">
nft Origin
</th>
<th className=" px-6 py-3">
nft Image
</th>
<th className=" px-6 py-3">
Total Price
</th>
</tr>
</thead>
<tbody className="overflow-y-scroll">
{nftinfo.map((nft) => (
<tr className=" hover:bg-zinc-700 ">
<th scope="row" className="px-6 py-4 font-medium text-white ">
</th>
<td className="px-6 py-4">{nft.status}</td>
<td className="px-6 py-4">{nft.size}</td>
<td className="px-6 py-4">{nft.type}</td>
<td className="px-6 py-4">{nft.origin}</td>
<td className="px-6 py-4">{nft.image}</td>
<td
className={`px-6 py-4 ${
nft.totalprice > 5000
? ` text-green-500`
: `text-red-500`
}`}
>
$ {nft.totalprice}
</td>
</tr>
))}
</tbody>
</table>
</div>
You can use the below table to I have created, just make sure to replace class to className and do changes accordingly.
Try to watch the below code with full page as it is for desktop screen and do changes according to mobile view if you want.
<script src="https://cdn.tailwindcss.com"></script>
<div class="container m-auto p-4">
<h1 class="mb-8 text-center text-3xl font-bold">Scrollable Table Fixed Height</h1>
<table class="w-full border-[1px] border-black text-left">
<thead class="flex w-full bg-[#292A33] text-xs text-gray-400">
<tr class="flex w-full hover:bg-zinc-700">
<th class="w-1/4 p-4">NFT NAME</th>
<th class="w-1/4 p-4">NFT STATUS</th>
<th class="w-1/4 p-4">NFT SIZE</th>
<th class="w-1/4 p-4">NFT TYPE</th>
<th class="w-1/4 p-4">NFT ORIGIN</th>
<th class="w-1/4 p-4">NFT IMAGE</th>
<th class="w-1/4 p-4">TOTAL PRICE</th>
</tr>
</thead>
<!-- Remove the nasty inline CSS fixed height on production and replace it with a CSS class — this is just for demonstration purposes! -->
<tbody class="flex w-full flex-col items-center justify-between overflow-y-scroll bg-white text-gray-400" style="height: 60vh;">
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
<tr class="flex w-full hover:bg-zinc-700">
<td class="w-1/4 p-4">nft.name</td>
<td class="w-1/4 p-4">nft.status</td>
<td class="w-1/4 p-4">nft.size</td>
<td class="w-1/4 p-4">nft.type</td>
<td class="w-1/4 p-4">nft.origin</td>
<td class="w-1/4 p-4">nft.image</td>
<td class="w-1/4 p-4">total price</td>
</tr>
</tbody>
</table>
</div>
Can someone please provide some tip how to solve this issue with my script?
Script description:
Its script which creates HTML signature from GUI created in WPF.
Problem description:
First run script with WPF creates folder with right name, copy images and create HTML with right name but HTML file is blank only with images. After second run of script the folder, html file and images are filled right but with information from first run.
I guess it has something with $Global variables, because this issue is detected after i add in some $Global vars.
Thank you for any help.
PS1. script:
Add-Type -Name Window -Namespace Console -MemberDefinition
[DllImport("Kernel32.dll")]
public static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);'
[Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0)
#-------------------------------------------------------------#
#----Initial Declarations-------------------------------------#
#-------------------------------------------------------------#
Add-Type -AssemblyName PresentationCore, PresentationFramework
$Xaml = #"
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Width="647" Height="630" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:src="clr-namespace:ListBoxStyle">
<Window.Resources>
<Style x:Key="_ListBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Name="_Border" Padding="2" SnapsToDevicePixels="true">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="_Border" Property="Background" Value="#18509c"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid Name="GTX_Podpis" Margin="-2,-1,2,1" MinWidth="1500" MinHeight="1000">
<Image HorizontalAlignment="Left" Height="112" VerticalAlignment="Top" Width="137" Margin="10.84375,11,0,0" Name="Gumotex" Source="\\gtxdc1\Skupiny\Posta podpisy\Husařík_Jakub\logo_gumotex.png"/>
<TextBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" VerticalAlignment="Top" Height="30" Width="120" TextWrapping="Wrap" Margin="185,24,0,0" Name="TitulPred" Tag="TitulPred" Text="" ToolTip="TitulPřed"/>
<TextBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" VerticalAlignment="Top" Height="30" Width="120" TextWrapping="Wrap" Margin="321,24,0,0" Name="TitulZa" Tag="TitulZa" Text="" ToolTip="TitulZa"/>
<TextBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" VerticalAlignment="Top" Height="30" Width="181" TextWrapping="Wrap" Margin="187,76,0,0" Name="Jmeno" ToolTip="Jméno" Text="" Tag="Jmeno"/>
<TextBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" VerticalAlignment="Top" Height="30" Width="181" TextWrapping="Wrap" Margin="187,133,0,0" Name="Prijmeni" Tag="Prijmeni" Text="" ToolTip="Přijmeni"/>
<TextBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" VerticalAlignment="Top" Height="30" Width="181" TextWrapping="Wrap" Margin="189,183,0,0" Name="Funkce" Tag="Funkce" Text="" ToolTip="Funkce"/>
<TextBox HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="181" TextWrapping="Wrap" Margin="189,235,0,0" Name="Email" BorderBrush="#18509c" BorderThickness="2"/>
<TextBox HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="181" TextWrapping="Wrap" Margin="190,290,0,0" Name="Mobil" BorderBrush="#18509c" BorderThickness="2"/>
<TextBox HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="181" TextWrapping="Wrap" Margin="189,349,0,0" Name="PevnaLinka" BorderBrush="#18509c" BorderThickness="2"/>
<ListBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" Height="88" VerticalAlignment="Top" Width="164" Margin="7,75,0,0" Name="Divize" Tag="Divize" ToolTip="Divize" Foreground="#000000" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ItemContainerStyle="{DynamicResource _ListBoxItemStyle}"
>
<ListBoxItem Content="DIVIZE SERVICE"/>
<ListBoxItem Content="DIVIZE COATING"/>
<ListBoxItem Content="AUTOMOTIVE DIVISION"/>
<ListBoxItem Content="COATING DIVISION"/>
</ListBox>
<ListBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" Height="304" VerticalAlignment="Top" Width="243" Margin="387,75,0,0" Name="Zavod" Tag="Závod" ToolTip="Závod" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ItemContainerStyle="{DynamicResource _ListBoxItemStyle}"
>
<ListBoxItem Content="PRÁZDNÉ"/>
<ListBoxItem Content="ZÁVOD BŘECLAV"/>
<ListBoxItem Content="ZÁVOD TŘEBÍČ"/>
<ListBoxItem Content="ZÁVOD JAROMĚŘ"/>
<ListBoxItem Content="ZÁVOD MYJAVA"/>
<ListBoxItem Content="ZÁVOD ROŽNOV"/>
<ListBoxItem Content="PRODUCTION PLANT BRECLAV"/>
<ListBoxItem Content="PRODUCTION PLANT TREBIC"/>
<ListBoxItem Content="PRODUCTION PLANT JAROMER"/>
<ListBoxItem Content="PRODUCTION PLANT MYJAVA"/>
<ListBoxItem Content="PRODUCTION PLANT ROZNOV"/>
<ListBoxItem Content="ENGINEERING DEPARTMENT BRECLAV"/>
<ListBoxItem Content="ENGINEERING DEPARTMENT TREBIC"/>
<ListBoxItem Content="ENGINEERING DEPARTMENT JAROMER"/>
<ListBoxItem Content="ENGINEERING DEPARTMENT MYJAVA"/>
<ListBoxItem Content="ENGINEERING DEPARTMENT ROZNOV"/>
</ListBox>
<ListBox HorizontalAlignment="Left" BorderBrush="#18509c" BorderThickness="2" Height="109" VerticalAlignment="Top" Width="164" Margin="7,184,0,0" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
ItemContainerStyle="{DynamicResource _ListBoxItemStyle}" Name = "Adresa"
>
<ListBoxItem Content="BŘECLAV"/>
<ListBoxItem Content="TŘEBÍČ"/>
<ListBoxItem Content="JAROMĚŘ"/>
<ListBoxItem Content="MYJAVA"/>
<ListBoxItem Content="ROŽNOV"/>
</ListBox>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Adresa" Margin="9,164,0,0" Name="AdresaLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Divize" Margin="8,54,0,0" Name="DivizeLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="TitulPred" Margin="184,5,0,0" Name="TitulPredLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Jméno" Margin="188,56,0,0" Name="JmenoLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="TitulZa" Margin="321,5,0,0" Name="TitulZaLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Přijmení" Margin="187,112,0,0" Name="PrijmeniLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Funkce" Margin="188,164,0,0" Name="FunkceLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Závod" Margin="388,55,0,0" Name="ZavodLabel"/>
<Button Content="Vytvoř podpis" HorizontalAlignment="Left" VerticalAlignment="Top" Width="224" Margin="6,527,0,0" Name="VytvorPodpisButton" Background="#18509c" Foreground="#efefef" Height="55" FontSize="15"/>
<Button Content="Zavřít" HorizontalAlignment="Left" VerticalAlignment="Top" Width="224" Margin="403,529,0,0" Height="55" Name="ZavritButton" Background="#18509c" Foreground="#ffffff" FontSize="15"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Email" Margin="189,214,0,0" Name="EmalLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Mobil" Margin="190,267,0,0" Name="MobilLabel"/>
<Label HorizontalAlignment="Left" VerticalAlignment="Top" Content="Pevná linka" Margin="189,327,0,0" Name="PevnaLinkaLabel"/>
</Grid>
</Window>
"#
#-------------------------------------------------------------#
#----Global variables-----------------------------------#
#-------------------------------------------------------------#
$Global:ZavodHTML
$Global:AdresaInHTML
# Břeclav
$Global:VarAdresaBreclavUlice = "Mládežnická 3062/3a"
$Global:VarAdresaBreclavMesto = "690 02 Břeclav"
$Global:VarAdresaBreclavStat = "Česká republika"
$Global:VarAdresaBreclav
# Jaroměř
$Global:VarAdresaJaromerUlice = "V Lužinách 113, Pražské Předměstí"
$Global:VarAdresaJaromerMesto = "551 01 Jaroměř"
$Global:VarAdresaJaromerStat = "Česká republika"
$Global:VarAdresaJaromer
# Třebíč
$Global:arAdresaTrebicUlice = "Žďárského 184"
$Global:VarAdresaTrebicvMesto = "674 01 Kožichovice"
$Global:VarAdresaTrebicvStat = "Česká republika"
$Global:VarAdresaTrebic
# Myjava
$Global:VarAdresaMyjavaUlice = "Prostredná 1227/9"
$Global:VarAdresaMyjavavMesto = "907 01 Myjava"
$Global:VarAdresaMyjavaStat = "Slovenská republika"
$Global:VarAdresaMyjava
# Rožnov
$Global:VarAdresaRoznovUlice = "Televizní 2614"
$Global:VarAdresaRoznovMesto = "756 61 Rožnov pod Radhoštěm"
$Global:VarAdresaRoznovStat = "Česká republika"
$Global:VarAdresaRoznov
# Právní odstavce
#...........................................................................................................................................................................
# Český odstavec
$HTMLTextPravoS = #"
Tato zpráva má pouze informativní charakter. Obsah této zprávy obchodní společnost GUMOTEX, akciová společnost, ani žádnou jinou osobu, která s ní tvoří koncern (dále jen "GUMOTEX"), nezavazuje. GUMOTEX nemá v úmyslu touto zprávou jakoukoliv smlouvu uzavřít, přijmout nabídku nebo uzavření jakékoliv smlouvy potvrdit a zpráva ani nezakládá jeho předsmluvní odpovědnost. Kterákoliv smlouva pro GUMOTEX závazná musí mít výhradně tištěnou písemnou formu, náležitosti dle příslušných právních předpisů a musí být podepsána osobou, která je za GUMOTEX oprávněna jednat nebo GUMOTEX zastupovat. Tato zpráva může obsahovat důvěrné informace. Pokud nejste jejím určeným příjemcem, jakékoliv její zveřejnění, kopírování, rozesílání nebo jiné užití jejího obsahu je přísně zakázáno. Nejste-li určeným příjemcem zprávy, informujte v takovém případě prosím ihned jejího odesílatele a poté zprávu, včetně případných příloh, bezodkladně z Vašeho zařízení smažte.
"#
# Anglický odstavec
$HTMLTextPravoENS =
#"
This e-mail message is intended only for informational purposes. The content of this message is not binding for neither the company GUMOTEX, akciová společnost, nor any other entity forming the GUMOTEX Group (hereinafter „GUMOTEX“). GUMOTEX does not intend to conclude any agreements, to accept any offers or to confirm the conclusion of any contracts via this message. This message shall not give rise to GUMOTEX precontractual liability. Any agreement binding GUMOTEX shall be in a written form and printed, shall comply with all statutory requirements and shall be signed by a person authorized to act on behalf of or for GUMOTEX. This e-mail message may contain confidential information. If you are not the intended recipient of this message, any disclosure, copying, distribution or use of its contents is strictly prohibited. Please notify the sender immediately and delete the message (including any attachments) from your system.
"#
#...........................................................................................................................................................................
#-------------------------------------------------------------#
#----HTML-----------------------------------------------------#
#-------------------------------------------------------------#
$HTML = #"
<!DOCTYPE html>
<html lang="cs">
<head>
<title>Mail signature</title>
<meta charset="Windows-1250">
<style>
a {
text-decoration: none;
color: #000000;
}
a:hover {
color: #20549A;
}
a:active {
color: #20549A;
</style>
</head>
<body>
<table>
<tr>
<td style="font-family: arial; font-weight: bold; color: #000000; font-size: 16px;">$($TitulPred.Text+$Jmeno.Text+" "+$Prijmeni.Text + $TitulZa.Text)</td>
</tr>
<td style="font-family: arial;font-size: 1px;"> </td>
</tr>
<tr>
<td style="font-family: arial; color: #434442; font-size: 14px;">$($Funkce.Text)</td>
</tr>
$Global:ZavodHTML
<tr>
<td style="font-family: arial; color: #20549A; font-weight: bold; font-size: 14px;">$(($Divize.SelectedItem.Content))</td>
</tr>
</tr>
<td style="font-family: arial;font-size: 10px;"> </td>
</tr>
<tr>
<td><img src="logo_gumotex.png" alt="GUMOTEX"></td>
</tr>
<td style="font-family: arial;font-size: 8px;"> </td>
</tr>
</tr>
</table>
<table>
<tr>
<td><img src="icon_envelope_2.png" alt="Email"></td>
<td style="vertical-align: middle;font-family: arial; color: #000000; font-size: 12px;"> $($Email.Text)</td>
</tr>
<!-- Zde bude promenna pro logiku telefonniho a mobilniho cisla -->
<tr>
<td><img src="icon_phone_2.png" alt="$AliasS"></td>
<td style="vertical-align: middle;font-family: arial; color: #000000; font-size: 12px;"> +$FullTelefonS | +$MobilS</td>
</tr>
</table>
$Global:AdresaInHTML
<table>
<tr>
<td><img src="icon_web_2.png" alt="Web"></td>
<td><img src="icon_fb_2.png" alt="Facebook"></td>
<td><img src="icon_ln_2.png" alt="Linkedin"></td>
<td><img src="icon_yt_2.png" alt="YouTube"></td>
</tr>
</table>
<span style="font-family: arial; color: #8f8f8f; font-size: 9px;">
<table>
</tr>
<td style="font-family: arial;font-size: 4px;"> </td>
</tr>
</table>
$TextPravoS
<table>
</tr>
<td style="font-family: arial;font-size: 4px;"> </td>
</tr>
</table>
$TextPravoENS
<table>
</tr>
<td style="font-family: arial;font-size: 1px;"> </td>
</tr>
</table>
</span>
</body>
</html>
"#
#-------------------------------------------------------------#
#----Control Event Handlers-----------------------------------#
#-------------------------------------------------------------#
#Write your code here
$Window = [Windows.Markup.XamlReader]::Parse($Xaml)
[xml]$xml = $Xaml
$xml.SelectNodes("//*[#Name]") | ForEach-Object { Set-Variable -Name $_.Name -Value $Window.FindName($_.Name) }
#-------------------------------------------------------------#
#----Functions------------------------------------------------#
#-------------------------------------------------------------#
# Formátuje Mobil/Pevnou linku z formátu +420XXXXXXXXX na +420 XXX XXX XXX
<#
Function Format-Contact {
param (
[String]$FormatPevnaLinka,
[String]$FormatMobil
)
if (![String]::IsNullOrWhitespace($PevnaLinka.Text)) {
$HTMLFullTelefonS = $FormatPevnaLinka.Insert(4," ").Insert(8," ").Insert(12," ")
}
if (![String]::IsNullOrWhitespace($Mobil.Text)) {
$HTMLMobilS = $FormatMobil.Insert(4," ").Insert(8," ").Insert(12," ")
}
}
#>
function CreateFolder_forSignature {
$FolderName = $Jmeno.Text +"_"+ $Prijmeni.Text
If(!(Test-path -path "\\gtxdc1.gumotex.cz\Skupiny\posta podpisy\$FolderName"))
{
New-Item -ItemType Directory -Force -Path "\\gtxdc1.gumotex.cz\Skupiny\Posta podpisy\" -Name $FolderName
}
else {
[System.Windows.MessageBox]::Show("Složka $FolderName na síťovém disku:\\gtxdc1\skupiny\posta podpisy\ již existuje, pokud chcete vytvořit znovu tuto složku prosím smažte/přejmenujte/přesuňte stávající složku.")
}
}
function CopyImages_ToNewFolder {
$FolderName = $Jmeno.Text +"_"+ $Prijmeni.Text
Copy-Item -Path "\\gtxdc1\skupiny\posta podpisy\Obrazky\*" -Destination "\\gtxdc1\skupiny\posta podpisy\$FolderName" -Recurse
}
# Functions
# Funkce pro logiku Zavodu
function CreateZavod_toHTML {
<#if ($Zavod.SelectedItem.Content -eq "PRÁZDNÉ")
{
$Global:ZavodHTML = $null
}
else {#>
$Global:ZavodHTML = #"
<tr>
<td style="font-family: arial; color: #20549A; font-weight: bold; font-size: 14px;">$($Zavod.SelectedItem.Content)</td>
</tr>
"#
}
# Funkce pro logiku Adresy
function CreateAddress_ToHTML {
$VarUlice
$VarMesto
$VarStat
switch ($Adresa.SelectedItem.Content) {
"BŘECLAV" {
$VarUlice = $Global:VarAdresaBreclavUlice
$VarMesto = $Global:VarAdresaBreclavMesto
$VarStat = $Global:VarAdresaBreclavStat
}
"TŘEBÍČ" {
$VarUlice = $Global:VarAdresaTrebicUlice
$VarMesto = $Global:VarAdresaTrebicvMesto
$VarStat = $Global:VarAdresaTrebicvStat
}
"JAROMĚŘ" {
$VarUlice = $Global:VarAdresaJaromerUlice
$VarMesto = $Global:VarAdresaJaromerMesto
$VarStat = $Global:VarAdresaJaromerStat
}
"MYJAVA" {
$VarUlice = $Global:VarAdresaMyjavaUlice
$VarMesto = $Global:VarAdresaMyjavavMesto
$VarStat = $Global:VarAdresaMyjavaStat
}
"ROŽNOV" {
$VarUlice = $Global:VarAdresaRoznovUlice
$VarMesto = $Global:VarAdresaRoznovMesto
$VarStat = $Global:VarAdresaRoznovStaT
}
}
$Global:AdresaInHTML = #"
<table>
</tr>
<td style="font-family: arial;font-size: 4px;"> </td>
</tr>
<tr>
<td style="font-family: arial; color: #717270; font-size: 11px;">$VarUlice</td>
</tr>
<tr>
<td style="font-family: arial; color: #717270; font-size: 11px;">$VarMesto</td>
</tr>
<tr>
<td style="font-family: arial; color: #717270; font-size: 11px;">$VarStat</td>
</tr>
</tr>
<td style="font-family: arial;font-size: 10px;"> </td>
</tr>
</table>
"#
}
function CreateHTMLSignature {
$FolderName = $Jmeno.Text +"_"+ $Prijmeni.Text
$FileName = $Jmeno.Text +"_"+ $Prijmeni.Text + ".html"
New-Item -ItemType File -Path "\\gtxdc1\Skupiny\Posta podpisy\$FolderName\" -Name $FileName
Set-Content -Path "\\gtxdc1\Skupiny\Posta podpisy\$FolderName\$FileName" -Value $HTML
}
$ZavritButton.Add_Click({
$Window.Close()
})
$VytvorPodpisButton.Add_Click({
CreateFolder_forSignature
CopyImages_ToNewFolder
CreateAddress_ToHTML
CreateZavod_toHTML
CreateHTMLSignature
$Window.Close()
})
#endregion
#-------------------------------------------------------------#
#----Script Execution-----------------------------------------#
#-------------------------------------------------------------#
#Format-Contact -FormatPevnaLinka $PevnaLinka.Text -FormatMobil $Mobil.Text
$Window.ShowDialog()
solution founded: At beginning of script i put this line of code:Remove-Variable * -ErrorAction SilentlyContinue Which is solved the issue
My code
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=0,totalNums,totalNum,j=0;
size_t count;
float numbers[20][100];
char *line = malloc(100);
FILE *myFile;
myFile = fopen("vel.txt", "r");
if (myFile == NULL)
{
printf("Error Reading File\n");
exit (0);
}
while(getline(&line, &count, myFile)!=-1) {
for (; count > 0; count--, j++)
sscanf(line, "%f", &numbers[i][j]);
i++;
}
totalNums = 100;
totalNum = 20;
for (i=0 ; i<totalNums ; i++) {
for (j=0 ; j<totalNum ; j++) {
printf("\n%f", numbers[i][j]);
}
}
fclose(myFile);
return 0;
}
My goal is to read 2d array.
My vel.txt
2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0
2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0
2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0 2900.0
3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0
3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0
3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0
3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0 3600.0
4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0
4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0 4700.0
4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5100.0 5100.0 5100.0 5100.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 4900.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5100.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0 5400.0
I have compiled with gcc my code but I got :
milenko#milenko-HP-Compaq-6830s:~$ ./n1
Segmentation fault (core dumped)
Why?
Some bugs:
float numbers[20][100]; is a 20 x 100 array. This:
totalNums = 100;
totalNum = 20;
for (i=0 ; i<totalNums ; i++) {
for (j=0 ; j<totalNum ; j++) {
printf("\n%f", numbers[i][j]);
}
}
iterates over a 100 x 20 array. The use of better variable names than "totalNums" (for example something like max_x and max_y) would likely have eliminated this bug.
count is uninitialized before use. Enable compiler warnings.
You don't free() the variable line anywhere. Actually there is no reason to use dynamic allocation here at all.
fix like this
size_t count=0;
float numbers[20][100];
char *line = NULL;
...
while(i < 20 && getline(&line, &count, myFile)!=-1) {
int len = 0, pos = 0;
j = 0;
while(j < 100 && 1 == sscanf(line + pos, "%f%n", &numbers[i][j++], &len))
pos += len;
i++;
}
free(line);
totalNums = i;
totalNum = 100;//j;
The following code:
while(getline(&line, &count, myFile)!=-1) {
for (; count > 0; count--, j++)
sscanf(line, "%f", &numbers[i][j]);
i++;
}
Will put in count the** number of bytes read**. But in next line, you consider it as the number of numbers to read... And on number is at least composed of 2 bytes (one per character + one for the space).
You should try to read the line with some function like strtok. Warning, this function is not so trivial to use, read carrefully the documentation.
Your count is not initialized before calling getline, try this:
size_t count = 100;
char *line = malloc(count);
while(getline(&line, &count, myFile)!=-1) { ... }
Ok so I am slowly making headway on my project but I am recieving the follwoing error message:
"An SqlParameter with ParameterName 'Name' is not contained by this SqlParameterCollection."
The error points to the following statement in my vb code: e.Command.Parameters("Name").Value = NewName.Text
Could someone take a look at my code and help me with what I might b doing wrong.
Here is my vb code:
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Private Sub GridView1_RowCommand(sender As Object, e As GridViewCommandEventArgs) Handles Laboratory.RowCommand
' Insert data if the CommandName == "Insert"
' and the validation controls indicate valid data...
If e.CommandName = "Insert" AndAlso Page.IsValid Then
' Insert new record...
SqlDataSource2.Insert()
End If
End Sub
Protected Sub SqlDataSource2_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource2.Inserting
' Programmatically reference Web controls in the inserting interface...
Dim NewName As TextBox = Laboratory.FooterRow.FindControl("txtName")
Dim NewAddress As TextBox = Laboratory.FooterRow.FindControl("txtAddress")
Dim NewProvidence As TextBox = Laboratory.FooterRow.FindControl("txtProvidence")
Dim NewCity As TextBox = Laboratory.FooterRow.FindControl("txtCity")
Dim NewZipCode As TextBox = Laboratory.FooterRow.FindControl("txtZipCode")
Dim NewCountry As TextBox = Laboratory.FooterRow.FindControl("txtcountry")
Dim NewPhone As TextBox = Laboratory.FooterRow.FindControl("txtPhone")
Dim NewFax As TextBox = Laboratory.FooterRow.FindControl("txtFax")
Dim NewEmail As TextBox = Laboratory.FooterRow.FindControl("txtEmail")
' Set the ObjectDataSource's InsertParameters values...
' THIS IS WHERE I THINK I AM HAVING MY PROBLEM...
e.Command.Parameters("Name").Value = NewName.Text
e.Command.Parameters("Address").Value = NewAddress.Text
e.Command.Parameters("Providence").Value = NewProvidence.Text
e.Command.Parameters("City").Value = NewCity.Text
e.Command.Parameters("ZipCode").Value = NewZipCode.Text
e.Command.Parameters("Country").Value = NewCountry.Text
e.Command.Parameters("Phone").Value = NewPhone.Text
e.Command.Parameters("Fax").Value = NewFax.Text
e.Command.Parameters("Email").Value = NewEmail.Text
End Sub
And Here is my html.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<br />
<br />
<asp:GridView ID="Laboratory" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="LaboratoryID" DataSourceID="SqlDataSource2" ShowFooter="True">
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="AddRow" runat="server" CommandName="Insert" Text="Add" />
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name" SortExpression="Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address" SortExpression="Address">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Address") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtAddress" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Providence" SortExpression="Providence">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Providence") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtProvidence" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("Providence") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City" SortExpression="City">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("City") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtCity" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("City") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ZipCode" SortExpression="ZipCode">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("ZipCode") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtZipCode" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("ZipCode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Country" SortExpression="Country">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Country") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtCountry" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Country") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Phone" SortExpression="Phone">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("Phone") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtPhone" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Phone") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fax" SortExpression="Fax">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Fax") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtFax" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Fax") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email" SortExpression="Email">
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="TxtEmail" runat="server"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:GreatGrizzlyConnectionString1 %>" DeleteCommand="DELETE FROM [Laboratory] WHERE [LaboratoryID] = #LaboratoryID" InsertCommand="INSERT INTO [Laboratory] ([Name], [Address], [Providence], [City], [ZipCode], [Country], [Phone], [Fax], [Email]) VALUES (#Name, #Address, #Providence, #City, #ZipCode, #Country, #Phone, #Fax, #Email)" SelectCommand="SELECT * FROM [Laboratory]" UpdateCommand="UPDATE [Laboratory] SET [Name] = #Name, [Address] = #Address, [Providence] = #Providence, [City] = #City, [ZipCode] = #ZipCode, [Country] = #Country, [Phone] = #Phone, [Fax] = #Fax, [Email] = #Email WHERE [LaboratoryID] = #LaboratoryID">
<DeleteParameters>
<asp:Parameter Name="LaboratoryID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="Providence" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Email" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="Providence" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="Country" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LaboratoryID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
You need to create your parameters, there are lots of variations possible but here is a simple one
Dim Name As New SqlParameter("#Name", SqlDbType.nvarchar(50))
Name.Value = txtName.text
e.Command.Parameters.Add(Name)
You would need to do this for each parameter.
If the parameter already exists then you dont need to create it! You would just use the following. All I added was the "#" to your original code.
e.Command.Parameters("#Name").Value = NewName.Text
(It has been a while since I worked on this stuff.)
I'm currently working on a simple xml viewer control to display some xml files with easy navigation possibilities, like when you open a xml file in the internet explorer.
For this I found a nice control in the msdn forums:
<UserControl x:Class="WpfApplication1.CustomControl.Viewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xmlstack="clr-namespace:System.Xml;assembly=System.Xml">
<UserControl.Resources>
<SolidColorBrush x:Key="xmlValueBrush" Color="Blue" />
<SolidColorBrush x:Key="xmAttributeBrush" Color="Red" />
<SolidColorBrush x:Key="xmlTagBrush" Color="DarkMagenta" />
<SolidColorBrush x:Key="xmlMarkBrush" Color="Blue" />
<DataTemplate x:Key="attributeTemplate">
<StackPanel Margin="3,0,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock Foreground="{StaticResource xmAttributeBrush}" Text="{Binding Path=Name}" />
<TextBlock Foreground="{StaticResource xmlMarkBrush}" Text="="" />
<TextBlock Foreground="{StaticResource xmlValueBrush}" Text="{Binding Path=Value}" />
<TextBlock Foreground="{StaticResource xmlMarkBrush}" Text=""" />
</StackPanel>
</DataTemplate>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True" />
</Style>
<HierarchicalDataTemplate x:Key="treeViewTemplate" ItemsSource="{Binding XPath=child::node()}">
<StackPanel Margin="3,0,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock x:Name="startTag"
HorizontalAlignment="Center"
Foreground="{StaticResource xmlMarkBrush}"
Text="<" />
<TextBlock x:Name="xmlTag"
Margin="0"
HorizontalAlignment="Center"
Foreground="{StaticResource xmlTagBrush}"
Text="{Binding Path=Name}" />
<ItemsControl HorizontalAlignment="Center"
ItemsSource="{Binding Path=Attributes}"
ItemTemplate="{StaticResource attributeTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<TextBlock x:Name="endTag"
HorizontalAlignment="Center"
Foreground="{StaticResource xmlMarkBrush}"
Text=">" />
</StackPanel>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding NodeType}">
<DataTrigger.Value>
<xmlstack:XmlNodeType>Text</xmlstack:XmlNodeType>
</DataTrigger.Value>
<Setter TargetName="xmlTag" Property="Text" Value="{Binding InnerText}" />
<Setter TargetName="xmlTag" Property="Foreground" Value="Blue" />
<Setter TargetName="startTag" Property="Visibility" Value="Collapsed" />
<Setter TargetName="endTag" Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Binding="{Binding HasChildNodes}" Value="False">
<Setter TargetName="endTag" Property="Text" Value=" />" />
</DataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</UserControl.Resources>
<Grid>
<TreeView Name="xmlTree"
Grid.Row="2"
Grid.ColumnSpan="2"
ItemTemplate="{StaticResource treeViewTemplate}" />
</Grid>
</UserControl>
Code-Behind:
using System.Windows.Controls;
using System.Windows.Data;
using System.Xml;
namespace WpfApplication1.CustomControl
{
/// <summary>
/// Interaction logic for Viewer.xaml
/// </summary>
public partial class Viewer : UserControl
{
private XmlDocument _xmldocument;
public Viewer()
{
InitializeComponent();
}
public XmlDocument xmlDocument
{
get { return _xmldocument; }
set
{
_xmldocument = value;
BindXMLDocument();
}
}
private void BindXMLDocument()
{
if (_xmldocument == null)
{
xmlTree.ItemsSource = null;
return;
}
XmlDataProvider provider = new XmlDataProvider();
provider.Document = _xmldocument;
Binding binding = new Binding();
binding.Source = provider;
binding.XPath = "child::node()";
xmlTree.SetBinding(TreeView.ItemsSourceProperty, binding);
}
}
}
My problem now is that I want to display the ending tag of child nodes, in the following example marked with stars:
<root>
<node>Test*</node>*
*</root>*
I don't know how to realize this, are there good suggestions?
Thank you in advance.
I solved it by using the WebBrowser control.
I found no good solution with TreeView, but I'm full satisfied with this code, because it's full MVVM:
Create a dependency property for WebBrowser controls called BindableXmlData:
Public Class AttachedWebBrowserProperties
#Region "BindableXmlDataProperty"
Public Shared ReadOnly BindableXmlDataProperty As DependencyProperty = _
DependencyProperty.RegisterAttached("BindableXmlData", _
GetType(String), _
GetType(AttachedWebBrowserProperties), _
New UIPropertyMetadata(Nothing, AddressOf BindableXmlDataPropertyChanged))
Public Shared Function GetBindableXmlData(ByVal obj As DependencyObject) As ICommand
Return CType(obj.GetValue(BindableXmlDataProperty), ICommand)
End Function
Public Shared Sub SetBindableXmlData(ByVal obj As DependencyObject, ByVal value As String)
obj.SetValue(BindableXmlDataProperty, value)
End Sub
Public Shared Sub BindableXmlDataPropertyChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim browser As WebBrowser = TryCast(d, WebBrowser)
If browser IsNot Nothing Then
Dim xmldata As String = TryCast(e.NewValue, String)
If xmldata IsNot Nothing Then
browser.NavigateToString(xmldata)
End If
End If
End Sub
#End Region
End Class
Then add a new file to your solution called XmlToHtmlStylesheet.xslt as embedded resource with following content:
<!--
|
| XSLT REC Compliant Version of IE5 Default Stylesheet
|
| Original version by Jonathan Marsh (jmarsh#xxxxxxxxxxxxx)
| http://msdn.microsoft.com/xml/samples/defaultss/defaultss.xsl
|
| Conversion to XSLT 1.0 REC Syntax by Steve Muench (smuench#xxxxxxxxxx)
|
+-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="no" method="html"/>
<xsl:template match="/">
<HTML>
<HEAD>
<SCRIPT>
<xsl:comment>
<![CDATA[
function f(e){
if (e.className=="ci") {
if (e.children(0).innerText.indexOf("\n")>0) fix(e,"cb");
}
if (e.className=="di") {
if (e.children(0).innerText.indexOf("\n")>0) fix(e,"db");
} e.id="";
}
function fix(e,cl){
e.className=cl;
e.style.display="block";
j=e.parentElement.children(0);
j.className="c";
k=j.children(0);
k.style.visibility="visible";
k.href="#";
}
function ch(e) {
mark=e.children(0).children(0);
if (mark.innerText=="+") {
mark.innerText="-";
for (var i=1;i<e.children.length;i++) {
e.children(i).style.display="block";
}
}
else if (mark.innerText=="-") {
mark.innerText="+";
for (var i=1;i<e.children.length;i++) {
e.children(i).style.display="none";
}
}
}
function ch2(e) {
mark=e.children(0).children(0);
contents=e.children(1);
if (mark.innerText=="+") {
mark.innerText="-";
if (contents.className=="db"||contents.className=="cb") {
contents.style.display="block";
}
else {
contents.style.display="inline";
}
}
else if (mark.innerText=="-") {
mark.innerText="+";
contents.style.display="none";
}
}
function cl() {
e=window.event.srcElement;
if (e.className!="c") {
e=e.parentElement;
if (e.className!="c") {
return;
}
}
e=e.parentElement;
if (e.className=="e") {
ch(e);
}
if (e.className=="k") {
ch2(e);
}
}
function ex(){}
function h(){window.status=" ";}
document.onclick=cl;
]]>
</xsl:comment>
</SCRIPT>
<STYLE>
BODY {font:x-small 'Verdana'; margin-right:1.5em}
.c {cursor:hand}
.b {color:red; font-family:'Courier New'; font-weight:bold;
text-decoration:none}
.e {margin-left:1em; text-indent:-1em; margin-right:1em}
.k {margin-left:1em; text-indent:-1em; margin-right:1em}
.t {color:#990000}
.xt {color:#990099}
.ns {color:red}
.dt {color:green}
.m {color:blue}
.tx {font-weight:bold}
.db {text-indent:0px; margin-left:1em; margin-top:0px;
margin-bottom:0px;padding-left:.3em;
border-left:1px solid #CCCCCC; font:small Courier}
.di {font:small Courier}
.d {color:blue}
.pi {color:blue}
.cb {text-indent:0px; margin-left:1em; margin-top:0px;
margin-bottom:0px;padding-left:.3em; font:small Courier;
color:#888888}
.ci {font:small Courier; color:#888888}
PRE {margin:0px; display:inline}
</STYLE>
</HEAD>
<BODY class="st">
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="processing-instruction()">
<DIV class="e">
<SPAN class="b">
<xsl:call-template name="entity-ref">
<xsl:with-param name="name">nbsp</xsl:with-param>
</xsl:call-template>
</SPAN>
<SPAN class="m">
<xsl:text><?</xsl:text>
</SPAN>
<SPAN class="pi">
<xsl:value-of select="name(.)"/>
<xsl:value-of select="."/>
</SPAN>
<SPAN class="m">
<xsl:text>?></xsl:text>
</SPAN>
</DIV>
</xsl:template>
<xsl:template match="processing-instruction('xml')">
<DIV class="e">
<SPAN class="b">
<xsl:call-template name="entity-ref">
<xsl:with-param name="name">nbsp</xsl:with-param>
</xsl:call-template>
</SPAN>
<SPAN class="m">
<xsl:text><?</xsl:text>
</SPAN>
<SPAN class="pi">
<xsl:text>xml </xsl:text>
<xsl:for-each select="#*">
<xsl:value-of select="name(.)"/>
<xsl:text>="</xsl:text>
<xsl:value-of select="."/>
<xsl:text>" </xsl:text>
</xsl:for-each>
</SPAN>
<SPAN class="m">
<xsl:text>?></xsl:text>
</SPAN>
</DIV>
</xsl:template>
<xsl:template match="#*">
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*/#*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
</SPAN>
<SPAN class="m">="</SPAN>
<B>
<xsl:value-of select="."/>
</B>
<SPAN class="m">"</SPAN>
</xsl:template>
<xsl:template match="text()">
<DIV class="e">
<SPAN class="b"> </SPAN>
<SPAN class="tx">
<xsl:value-of select="."/>
</SPAN>
</DIV>
</xsl:template>
<xsl:template match="comment()">
<DIV class="k">
<SPAN>
<A STYLE="visibility:hidden" class="b" onclick="return false" onfocus="h()">-</A>
<SPAN class="m">
<xsl:text><!--</xsl:text>
</SPAN>
</SPAN>
<SPAN class="ci" id="clean">
<PRE>
<xsl:value-of select="."/>
</PRE>
</SPAN>
<SPAN class="b">
<xsl:call-template name="entity-ref">
<xsl:with-param name="name">nbsp</xsl:with-param>
</xsl:call-template>
</SPAN>
<SPAN class="m">
<xsl:text>--></xsl:text>
</SPAN>
<SCRIPT>f(clean);</SCRIPT>
</DIV>
</xsl:template>
<xsl:template match="*">
<DIV class="e">
<DIV STYLE="margin-left:1em;text-indent:-2em">
<SPAN class="b">
<xsl:call-template name="entity-ref">
<xsl:with-param name="name">nbsp</xsl:with-param>
</xsl:call-template>
</SPAN>
<SPAN class="m"><</SPAN>
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
<xsl:if test="#*">
<xsl:text> </xsl:text>
</xsl:if>
</SPAN>
<xsl:apply-templates select="#*"/>
<SPAN class="m">
<xsl:text>/></xsl:text>
</SPAN>
</DIV>
</DIV>
</xsl:template>
<xsl:template match="*[node()]">
<DIV class="e">
<DIV class="c">
<A class="b" href="#" onclick="return false" onfocus="h()">-</A>
<SPAN class="m"><</SPAN>
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
<xsl:if test="#*">
<xsl:text> </xsl:text>
</xsl:if>
</SPAN>
<xsl:apply-templates select="#*"/>
<SPAN class="m">
<xsl:text>></xsl:text>
</SPAN>
</DIV>
<DIV>
<xsl:apply-templates/>
<DIV>
<SPAN class="b">
<xsl:call-template name="entity-ref">
<xsl:with-param name="name">nbsp</xsl:with-param>
</xsl:call-template>
</SPAN>
<SPAN class="m">
<xsl:text></</xsl:text>
</SPAN>
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
</SPAN>
<SPAN class="m">
<xsl:text>></xsl:text>
</SPAN>
</DIV>
</DIV>
</DIV>
</xsl:template>
<xsl:template match="*[text() and not (comment() or processing-instruction())]">
<DIV class="e">
<DIV STYLE="margin-left:1em;text-indent:-2em">
<SPAN class="b">
<xsl:call-template name="entity-ref">
<xsl:with-param name="name">nbsp</xsl:with-param>
</xsl:call-template>
</SPAN>
<SPAN class="m">
<xsl:text><</xsl:text>
</SPAN>
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
<xsl:if test="#*">
<xsl:text> </xsl:text>
</xsl:if>
</SPAN>
<xsl:apply-templates select="#*"/>
<SPAN class="m">
<xsl:text>></xsl:text>
</SPAN>
<SPAN class="tx">
<xsl:value-of select="."/>
</SPAN>
<SPAN class="m"></</SPAN>
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
</SPAN>
<SPAN class="m">
<xsl:text>></xsl:text>
</SPAN>
</DIV>
</DIV>
</xsl:template>
<xsl:template match="*[*]" priority="20">
<DIV class="e">
<DIV STYLE="margin-left:1em;text-indent:-2em" class="c">
<A class="b" href="#" onclick="return false" onfocus="h()">-</A>
<SPAN class="m"><</SPAN>
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
<xsl:if test="#*">
<xsl:text> </xsl:text>
</xsl:if>
</SPAN>
<xsl:apply-templates select="#*"/>
<SPAN class="m">
<xsl:text>></xsl:text>
</SPAN>
</DIV>
<DIV>
<xsl:apply-templates/>
<DIV>
<SPAN class="b">
<xsl:call-template name="entity-ref">
<xsl:with-param name="name">nbsp</xsl:with-param>
</xsl:call-template>
</SPAN>
<SPAN class="m">
<xsl:text></</xsl:text>
</SPAN>
<SPAN>
<xsl:attribute name="class">
<xsl:if test="xsl:*">
<xsl:text>x</xsl:text>
</xsl:if>
<xsl:text>t</xsl:text>
</xsl:attribute>
<xsl:value-of select="name(.)"/>
</SPAN>
<SPAN class="m">
<xsl:text>></xsl:text>
</SPAN>
</DIV>
</DIV>
</DIV>
</xsl:template>
<xsl:template name="entity-ref">
<xsl:param name="name"/>
<xsl:text disable-output-escaping="yes">&</xsl:text>
<xsl:value-of select="$name"/>
<xsl:text>;</xsl:text>
</xsl:template>
</xsl:stylesheet>
Create a new window (or in my case, a usercontrol):
<UserControl x:Class="AdditionalXmlView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:MyApplication.Framework">
<WebBrowser ui:AttachedWebBrowserProperties.BindableXmlData="{Binding XmlData}" />
</UserControl>
Create a viewmodel like this:
Imports System.Xml
Imports System.Xml.Xsl
Imports System.Text
Imports System.IO
Imports System.ComponentModel
Public Class AdditionalXmlViewModel
Implements INotifyPropertyChanged
Private _XmlData As String
Public Property XmlData() As String
Get
Return _XmlData
End Get
Set(ByVal value As String)
_XmlData = value
OnPropertyChanged("XmlData")
End Set
End Property
Public Sub LoadXmlData(ByVal xmlDocument As XmlDocument)
Dim sb As New StringBuilder(2500)
Dim xslt As New XslCompiledTransform()
Dim stylesheetStream As Stream = GetType(AdditionalXmlView).Assembly.GetManifestResourceStream("MyApplication.Framework.XmlToHtmlStylesheet.xslt")
If stylesheetStream IsNot Nothing Then
Dim xmlReader As XmlReader = xmlReader.Create(stylesheetStream)
xslt.Load(xmlReader)
Dim settings As New XmlWriterSettings()
Dim dest As XmlWriter = XmlWriter.Create(sb, settings)
xslt.Transform(xmlDocument, dest)
End If
XmlData = sb.ToString()
End Sub
Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Public Sub OnPropertyChanged(ByVal propertyName As String)
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
End Sub
End Class
Create your view and viewmodel and set the xmldata:
Public Class XYZ
Private additionalView As AdditionalXmlView
Private additionalViewModel As AdditionalXmlViewModel
Private Sub CreateInstances()
additionalViewModel = New AdditionalXmlViewModel()
additionalView = New AdditionalXmlView()
additionalView.DataContext = additionalViewModel
End Sub
Private Sub SetXmlDataOfAdditionalView()
Dim xmlDocument As New XmlDocument()
xmlDocument.Load("myXmlFile.xml")
additionalViewModel.LoadXmlData(xmlDocument)
End Sub
End Class