|
Forget the Regex and go for somethying like...
sentence = sentence.Replace("Shipment ID: ", "");
sentence = sentence.Substring(0, sentence.IndexOf("Invoice No:"));
string[] numbers = sentence.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries);
return 5;
|
|
|
|
|
Hi,
I have another javascript on a poppup window in asp.net to return the value back to the parent .
but it gives me an error: opener.document is null or not an object.
opener.document.getElementById("TextBox1").value = "hello";
I even ammended the main parent javascript so as to open this popup as a return value back to a variable.
any help will be highly appreciated.
Thanks
|
|
|
|
|
You were told in your previous post to try Javascript forum. It seems that wasn't clear to you. This is wrong forum. Post your question in Javascript forum or Q & A with proper tags.
|
|
|
|
|
oh.. din't read that.. am deleting this now.
|
|
|
|
|
|
yes...
but i've changed this question to javascript forum..
thanks
|
|
|
|
|
See the code below, specifically the following line:
// ??? How do I access the TestProperty of oTest1, and instance of the Test1 class, which is a subclass of TestBase ???
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace TreadStackMemberAccess
{
public class Program
{
static void Main(string[] args)
{
Test1 oTest1 = new Test1();
oTest1.Method1();
}
}
public class TestBase
{
public string TestProperty { get; set; }
}
public class Test1 : TestBase
{
public void Method1()
{
TestProperty = "Test1";
Test2 oTest2 = new Test2();
oTest2.Method2();
}
}
public class Test2
{
public void Method2()
{
Test3 oTest3 = new Test3();
oTest3.Method3();
}
}
public class Test3
{
public void Method3()
{
System.Diagnostics.StackFrame[] oStackFrames = (new System.Diagnostics.StackTrace()).GetFrames();
for (int i = 0; i < oStackFrames.Length; i++)
{
System.Diagnostics.StackFrame oStackFrame = (System.Diagnostics.StackFrame)(oStackFrames[i]);
if (oStackFrame.GetMethod().ReflectedType.IsSubclassOf(typeof(TestBase)))
{
}
}
}
}
}
|
|
|
|
|
I am not too sure if StackFrame will give you the access to the instance. The list of properties and methods in the class clearly should that it is not straightforward. I do not think it will be possible even via reflection.
BTW, why do want to know which instance called the method? You may get replies with alternate approach.
|
|
|
|
|
Thanks for the reply.
I actually don't care which instance called the method, I just need to know it is a subclass of TestBase. I only called out the specific instance information here for clarity.
|
|
|
|
|
So you already have that code then isn't it? Although it can be done without StackFrame as well.
|
|
|
|
|
I have the code in place to use stack frames to determine if the caller, at some point in the stack frame, was a subclass of TestBase...but, I've failed to figure out how to access the object's TestProperty value.
|
|
|
|
|
That's what I have replied. I am not sure if it is possible at all. It tells the type but never gives you access to that very instance. If you just want to access that property information, this should help:
Type t = oStackFrame.GetMethod().ReflectedType;
PropertyInfo property = t.GetProperty("property name here");
|
|
|
|
|
I got to the point where I can create a PropetyInfo instance, but I cannot figure out how to use the PropertyInfo instance get the TestProperty string value.
Can you continue the code you sent to show accessing the actual property value (instead of just creating a PropertyInfo instance)?
Thanks
|
|
|
|
|
It's simple.
propertyInfo.GetValue(objectInstance, null);
|
|
|
|
|
I got that far too
But, I could never figure out how to access the object instance - i.e. what do you set the objectInstance to?
|
|
|
|
|
You cannot access that. I had told that in my first reply itself.
There is no way you can access oTest1 in Method2 through this approach.
|
|
|
|
|
You can't. The stack frame is not the object instance.
|
|
|
|
|
Any know how I can pull this off? Or, is this not possible in any manner?
|
|
|
|
|
Your Method3 should either take in a parameter of type Test1 or a parameter with type same as that of property you want to access.
|
|
|
|
|
Hi,
I have a simple javascript on my asp.net page where i have
document.getElementById("txtFirstName").value;
which gives a runtime error : object required.
can anyone please help. here txtFirstNa
me is the id of as:textbox control.
Thanks
|
|
|
|
|
Try
document.getElementById('<%= txtFirstName.ClientID %>').value
|
|
|
|
|
thanks karl.. it worked.
many thanks.
|
|
|
|
|
|
I apologize if this the wrong for this question.
I have a C# app, more of a framework really that does calculations on a large set of proprietary data, the data in its raw form is unreadable, it has to be processed by the framework. I'm wondering if there is a way to create a driver so that applications can query the framework much like you would query a database? I can put the data into datatables and datasets, but I'm not sure how to make it accessible. Any suggestions are appreciated.
|
|
|
|
|
You might consider using/creating a Domain Specific Language (DSL).
General description[^].
Microsoft's take[^].
For more information just google domain specific language.
That's all I know about them though, except that there are some articles here on The Code Project about them. (Use the Articles|Search menu at the top of the page).
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
|
|
|
|