|
what should i do now when i run the program and it has this error : "
Exception from HRESULT: 0x800A03EC
"
|
|
|
|
|
You could start by asking Google what the error code means. Then go back to your code, to the line where the error is produced, and try to work out what is wrong with your code or the data it is working on.
|
|
|
|
|
Your error seems to be excel related, you did however posted a one liner and expected the world to mind read what you meant.
I googled the error and it popped up with multiple solutions - Save me from this error[^]
and by selecting the first solution on SO, easy to fix - My error is fixed![^]
|
|
|
|
|
I am new to asp.net core. I have a form which is generated dynamically. I want the validation error message to be "The value must be numeric" instead I get "The value 'a' is invalid" when I submit the form.
Here is my View Model:
[RegularExpression("^[0-9]*$", ErrorMessage = "The value must be numeric")]
public List<int> Units_Service { get; set; }
Here is my form code:
for (int i = 0; i < Model.Workload_Category_Name.Count; i++)
{
<div class="row">
<div class="col-md-3">
<b></u>@Html.DisplayFor(model => model.Workload_Category_Name[i])</u> </b>
</div>
<div class="col-md-4">
@Html.TextBoxFor(model => model.Units_Service[i], new { style = "width: 15%", MaskedTextBox = "9999" })
@Html.ValidationMessageFor(model => model.Units_Service[i])
</div>
</div>
}
Despite the fact, I have put the custom error message in my View Model as shown above, I keep getting the default message "The value '' is invalid". Please what is the solution to this kind of scenario ?
|
|
|
|
|
The problem is, you're validating the Units_Service property, not the individual items within it.
And applying a regular expression validation to anything other than a string property makes no sense.
Probably the simplest option would be to create a viewmodel for each item in the list - for example:
public class UnitsServiceViewModel
{
[Required(ErrorMessage = "You must enter a value.")]
[RegularExpression("^[0-9]*$", ErrorMessage = "The value must be numeric.")]
public string Value { get; set; }
}
public class OuterViewModel
{
public List<UnitsServiceViewModel> Units_Service { get; set; }
internal List<int> Units_Service_Parsed
{
get
{
if (Units_Service is null) return null;
List<int> value = new(Units_Service.Count);
foreach (UnitsServiceViewModel vm in Units_Service)
{
int.TryParse(vm.Value, out int i);
value.Add(i);
}
return value;
}
set
{
if (value is null)
{
Units_Service = null;
}
else
{
List<UnitsServiceViewModel> list = new(value.Count);
foreach (int i in value)
{
list.Add(new() { Value = i.ToString() });
}
Units_Service = list;
}
}
}
}
@for (int i = 0; i < Model.Units_Service.Count; i++)
{
<div class="row">
<div class="col-md-3">
@Html.LabelFor(model => model.Units_Service[i].Value, Model.Workload_Category_Name[i])
</div>
<div class="col-md-4">
@Html.TextBoxFor(model => model.Units_Service[i].Value, new { style = "width: 15%", MaskedTextBox = "9999", inputmode = "numeric" })
@Html.ValidationMessageFor(model => model.Units_Service[i].Value)
</div>
</div>
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Richard. Your answer works perfect
|
|
|
|
|
Fokwa Divine wrote: "^[0-9]*$"
Note that this (and in the corrected code) allows for an empty string.
You probably want the following
^[0-9]+$
You might also want to check for limits. So is '0' a correct value? Is '1000000000'?
|
|
|
|
|
Thanks for your input jschell
Yes, I am checking for limit and '0' is a correct value per requirement
|
|
|
|
|
function to extract the nibbles from a given byte.
|
|
|
|
|
You seem to have mistaken this site for a search engine or AI chatbot.
We're more than happy to help you with problems with code you have written. But nobody here is going to do your work for you, even if you had asked politely.
Also, you've posted in the C# forum, but your message subject suggests you're working in C. Despite the similar names, those are to completely different languages. A solution for one probably won't work in the other.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This is easily accomplished using masking and bit-shifting. Do some research on how these work and you should be able to do it, and learn something interesting along the way.
|
|
|
|
|
I have a winform project where i am using web browser control which load a site. the site has many tabular data which is a html table. user will select large text from web browser control using their mouse. the select may have many data including multiple tabular data which is nothing but a html table.
I know how to get text from selection. this is sample code which return text.
private string GetSelectedText()
{
dynamic document = webBrowser1.Document.DomDocument;
dynamic selection = document.selection;
dynamic text = selection.createRange().text;
return (string)text;
}
But i need html of selected area on web browser control programmatically. i use a code sample which suppose to return html of selected portion of web page loaded into web browser control.....but no luck.
here i am sharing that code which not working as expected. please see my code and tell me how could grab the html content from web browser control of large selection ?
here is the code which is not working.
<pre>using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HtmlTableParser
{
public partial class Form2 : Form
{
private WebBrowser webBrowser1;
public Form2()
{
InitializeComponent();
Button btn = new Button();
btn.Text = "Test";
btn.Click += button1_Click;
this.Controls.Add(btn);
var panel = new Panel();
panel.Top = btn.Height + 2;
panel.Height = this.ClientSize.Height - btn.Height + 2;
panel.Width = this.ClientSize.Width;
panel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
webBrowser1 = new WebBrowser();
webBrowser1.Dock = DockStyle.Fill;
webBrowser1.Url = new Uri("https://www.sec.gov/Archives/edgar/data/1108134/000110813423000018/bhlb-20230630.htm");
panel.Controls.Add(webBrowser1);
this.Controls.Add(panel);
}
private void button1_Click(object sender, EventArgs e)
{
TestSelection();
TestAllTable();
}
private void TestSelection()
{
var domdoc = this.webBrowser1.Document.DomDocument as mshtml.IHTMLDocument2;
var sel = domdoc.selection;
var range = sel.createRange();
var trange = range as mshtml.IHTMLTxtRange;
var table = GetParentTable(trange.parentElement());
if (table == null)
{
var startPointRange = trange.duplicate();
startPointRange.setEndPoint("EndToStart", trange);
var startPointTable = GetParentTable(startPointRange.parentElement());
var endPointRange = trange.duplicate();
startPointRange.setEndPoint("StartToEnd", trange);
var endPointTable = GetParentTable(endPointRange.parentElement());
if (startPointTable != null)
{
table = startPointTable;
}
else if (endPointTable != null)
{
table = endPointTable;
}
else
{
MessageBox.Show("Selection is not in Table");
return;
}
}
var tableData = TableData.GetTableData(table);
System.Diagnostics.Debug.WriteLine(tableData.ToString());
}
private mshtml.IHTMLTable GetParentTable(mshtml.IHTMLElement element)
{
var parent = element;
while (parent != null)
{
if (parent is mshtml.IHTMLTable table)
{
return table;
}
parent = parent.parentElement;
}
return null;
}
private void TestAllTable()
{
var domdoc = this.webBrowser1.Document.DomDocument as mshtml.HTMLDocument;
foreach (var table in domdoc.getElementsByTagName("table").OfType<mshtml.IHTMLTable>())
{
var tableData = TableData.GetTableData(table);
System.Diagnostics.Debug.WriteLine(tableData.ToString());
System.Diagnostics.Debug.WriteLine(new string('=', 20));
}
}
}
class TableData
{
public static TableData GetTableData(mshtml.IHTMLTable table)
{
TableData tableData = new TableData();
foreach (var tableRow in table.rows.OfType<mshtml.IHTMLTableRow>())
{
RowData rowdata = new RowData();
foreach (var tablecell in tableRow.cells.OfType<mshtml.HTMLTableCell>())
{
CellData cell = new CellData();
cell.Text = tablecell.innerText;
cell.RowSpan = tablecell.rowSpan;
cell.ColSpan = tablecell.colSpan;
rowdata.Add(cell);
}
tableData.Rows.Add(rowdata);
}
return tableData;
}
public List<RowData> Rows { get; } = new List<RowData>();
public override string ToString()
{
System.Text.StringBuilder sb = new StringBuilder();
foreach (var row in this.Rows)
{
sb.AppendLine(row.ToString());
}
return sb.ToString();
}
}
class RowData : List<CellData>
{
public override string ToString()
{
return string.Join("\t", this.Select(cell => cell.Text + new string('\t', cell.ColSpan)));
}
}
class CellData
{
public string Text { get; set; }
public int ColSpan { get; set; }
public int RowSpan { get; set; }
public override string ToString() => Text;
}
}
Here i am pasting a image which show how user will selected the portion of page.
screen shot
It is my request that for last few days i have tried many approach to get html of selection portion from web browser control....but not succeeded. please some one help me with right approach.
Thanks
|
|
|
|
|
No new code should be written today using the ancient WebBrowser control. It's an instance of Internet Explorer, and unless you edit the registry on every single computer where your code runs, it's stuck in IE7-compatability mode.
Instead, use a modern control such as WebView2[^] (Edge), CefSharp[^] (Chrome), or GeckoFX[^] (Firefox).
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
WebView not available for .net core 6 winform project. can you suggest any browser control which i can use
.net core 6 winform project ?
Thanks
|
|
|
|
|
|
The API Documentation is no help. It assumes you will use POSTMAN to access the ADP API.
I need to run daily with a C# program to pull data.
Has anyone been able to build a C# program to integrate using the ADP API?
If so, can you sure some insights?
I've successfully integrated C# with PointClickCare's API and NetHealth's API, one using XML objects and the other using JSON objects.
|
|
|
|
|
If you use Postman 10.10.6 or later, it has built-in support for generating a C# snippet to replicate the Postman request. You can generate code that uses RestSharp, or code that uses the raw HttpClient.
Open a working request in Postman, and click on the </> icon on the right-hand side.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: it has built-in support for generating a C# snippet
Well that is interesting information. I would not have even thought to look for that.
|
|
|
|
|
trying to convert dataMember from int to Color
color1.DataBindings.Add("BackColor",NavBill.DataSource,"Color1" );
Control : color1 is panel
Binding dataMember : "Color1" is columns(int,null)
How can convert dataMemer value from (int) to (Color) before assignment to property?
|
|
|
|
|
Yes you just need to use a Format event handler on the Binding object
For example
private void AddBinding() {
Binding b = color1.DataBindings.Add("BackColor", NavBill.DataSource, "Color1", true);
b.Format += PanelBackColorBinding_Format;
}
private void PanelBackColorBinding_Format(Object sender, ConvertEventArgs e) {
if (e.DesiredType == typeof(Color)) {
Int32 number = (Int32)e.Value;
Color col = GetColor(number);
e.Value = col;
}
}
Make sure that a default color is assigned to e.Value if there is any chance that the column will have missing or non convertable values.
|
|
|
|
|
Hey Everyone:
I've never done something like this before - announcing the relase of my first NuGet package. (I've had a couple of others but they were really niche.) This is an extension to the MarkDig markdown parser in .NET 6, and I used a tutorial article from here to make it happen! Thanks @cyotek for the big help!
The source code - along with my hopefully coherent documentation - is available at:
GitHub - crazycga/Evergrowth.AspForMarkDigExtension: This is the source repository for the Asp-For MarkDig Extension.[^]
The NuGet package is called "Evergrowth.AspForMarkDigExtension".
What it does:
I had a situation where a client of mine wanted to use markdown to prepare some forms for clients. Semi-static stuff. I found that when I was parsing the markdown in the controller, it wasn't getting parsed properly to make use of the 'asp-for="<model name="">"' function to build input fields. I tilted at that windmill for a time, then decided it would be a good way to grow a little as a developer and get input on my stuff... So here we are.
Thanks everyone here who - over the years - has helped me immeasurably become better at this!
-J
|
|
|
|
|
Don't post this here - forums can move pretty rapidly, and once this scrolls off the first page it gets less likely that anyone will ever see it. Plus, it's kinda rude for a "technical forum" to be plugging your work, even a free to use nuget package.
Instead, have you considered posting the Github as a Project here? Provided your documentation is indeed coherent it should be pretty easy to do: Your GitHub Project on CodeProject[^] and that is more likely to be found.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Sorry didn't mean to be rude. Was trying to thank someone for their help and inspiration. And didn't want to have a huge long lasting thing so figured posting in a forum would be good, so that it was ephemeral. For some reason I can't seem to delete to post. If you can, please do so.
|
|
|
|
|
If you want to thank someone, reply to a comment they made, or post at the bottom of the article. That way they should notice it*
Why would you want your work to be ephemeral, if you are sharing it anyway?
You can't delete your post because it has a reply - that would "orphan" the response(s) and lose the meaning of the thread (obvious if you think about it). Yes I can delete the whole thread (all Protectors can) but it's not necessary it's only "slightly rude" not "you b*****d" rude! I wouldn't worry about it, but if you still want that, just say the word.
* Some people run with emails disabled, or deliberately use a dummy email so "@" messages may not get through at all.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Since the license makes it free you can post in the Free Tools forum.
|
|
|
|