|
This forum is for C# questions. See the SQL forum instead.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for telling me ! but I don't know if you Read my message !!!!
"I post this message in the Part Sql/ADO but no one answer !!! "
C# Forum have seen a lot more by developers !
|
|
|
|
|
Ok, here's the trick. I need to be able to compile code at run-time and then save the compiled code for later use so I don't have to compile it again. What's the trick to this? WHat should I be looking up? Should I be making an assembly, or is there a better way to do it?
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
Never mind, I missed the parameter that specifies the DLL to create :P
NATHAN RIDLEY
Web Application Developer
email: nathan @ netlab.com.au
[remove the spaces before and after the @ symbol]
|
|
|
|
|
Is it possible to use C# controls in a MFC Dialog based application. I have a C# control of a fancy button, and want to add this button on the MFC Dialog. Any help in this context will be much appreciated.
Regards
|
|
|
|
|
|
im trying to multiply some numbers num1 is a normal integer,(1,2,3....) and num2 is a decimal number(0.23,1.00,3.00....) im having problems multiplying them, i've done it different ways sometimes i get a 0 in the total textbox or this error : Input String was not in a correct format. Can somebody help me out to rectify this problem.
<br />
if(Pharma.Rows.Count != 0)<br />
{<br />
string Tablet = (string) Pharma.Rows[0][0];<br />
<br />
decimal num2 = Convert.ToDecimal(Tablet);<br />
<br />
MessageBox.Show(num2.ToString());
<br />
int num3 = Convert.ToInt32(num2);<br />
<br />
int num1 = Int32.Parse(txtQuantity.Text);<br />
<br />
MessageBox.Show(num1.ToString());
<br />
total = num1 * num3;<br />
<br />
decimal total1 = Convert.ToDecimal(total);<br />
<br />
MessageBox.Show(total.ToString());
<br />
txtMedTotal.Text = total.ToString();<br />
}<br />
else<br />
{<br />
MessageBox.Show("The Patient has yet to be processed","Information");<br />
}<br />
<br />
<br />
this code is givin me back a result of 0...when it should be 2.76
im three times confused now!
|
|
|
|
|
Hi
Where you Put
int num3 = Convert.ToInt32(num2);
Num2 turns to 0.because it has 0 as integer part.you better convert Num1 to Decimal !! or just Multiply Nme1 and Num2
|
|
|
|
|
Hello everybuddy,
I have a public property of type pClass in my component class. When I have my component on a design surface selected, in the property panel the pClass property exists but is disabled (faded to gray) while I want it to have a plus mark on the left so when clicked extend and show cClass public properties.
Can you help me?!
- Den2fly
---
"Art happens when you least expect it."
|
|
|
|
|
You need to implement a custom TypeConverter . You then attribute pClass or the property of that type (better on the class except in rare cases or when it's not possible - like for types that already have TypeConverter s) using the TypeConverterAttribute .
You can find more information about the TypeConverter class at http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemComponentModelTypeConverterClassTopic.asp[^]. You should also read Enhancing Design-Time Support[^], also in the .NET Framework SDK.
Finally, it may be read-only because the property does not have a setter (the set accessor of a property). Make sure that's not the case. The TypeConverter , though, can help you do many things, such as converting to and from a string representation of your class (like it does for Point , Size , Enum s, Font , etc. You can also use it to display a property set that is shown when you expand your property, like the Font class.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi guys,
I'm developing a web application which requires me to embed windows media player 9. This player will be able to choose from a combo box which server it wants to display video from. Now, the combo box is a web control which is declared and can be manipulated in .cs file, but how do I set the URL of the windows media player 9, which is a windows control, since it is not declared in the .cs file. It's only declared as an object on .aspx file. I've tried JavaScript but didn't work as well, always gives an error on page. My questions are:
1. Is there a way to convert the windows media player 9 to web control?
2. Do I have to add a reference? is it to wmp.dll or wmppia.dll? tried 'em but didn't work.
3. Or is there any other way so that I can do what I'm supposed to do?
Desperate for ur help guys...
thankz...
|
|
|
|
|
You can make any tag an HTML control simply by adding runat="server" to its attribute list. Unfortunately, this won't expose the functionality you need (which is basically to add a PARAM element inside the OBJECT tag with the necessary NAME and VALUE attributes (using "URL" for the NAME ). So, there are several alternatives. You could always output this element directly to the page using the old ASP-style output. Inside your OBJECT tag, put:
<% Response.Write(UrlPropertyValue) %> , where UrlPropertyValue is a field or property that contains your URL to play. You could also output a script using either Page.RegisterClientScriptBlock or Page.RegisterStartupScript (see the documentation for these to methods in the .NET Framework SDK for more information). So long as your OBJECT tag has an ID attribute, you can call methods and get/set properties using the ID. This is pretty common and works well when you do it correctly.
There was a WebControl that did much of this here on CodeProject, but I'll be jiggered that I can't find it. You can try searching for it in the ASP.NET section. Really, though, it just does pretty much what I described above.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I get what you mean, but I need to set URL based on the client input. Therefore, I have to do the URL settings on the .cs file. Because the comboBox is a web control, which is used as the user input, I have to take that value, which only can be done in .cs file (or isn't it?) and The windows media player is a windows control, which is not declared at all at the .cs file, which makes me impossible to set the URL of it. Do you have any other suggestions? I don't really want to use JavaScript unless I have to.
Please help me guys...
|
|
|
|
|
It doesn't HAVE to be in the .cs file. You can mix code in both the code-behind files and in the .aspx files. The .aspx derives from the class in your .cs file, which derives from the Page class (or any other class you have choosen). A good OO design would let you do it either way.
You can still include an HTML control that lets you programmatically assign attributes. You could either write your own (not hard - add a property and override Render to output the HTML with the assign URL) or use a generic HtmlControl in place of the param, which should work:
<object ...>
<param name="URL" value="" id="URLParam" runat="server"/>
<!-- ... -->
</object> Then in the page, make sure that a HtmlGenericControl is defined as protected. In your code, simply add the attribute value:
protected HtmlGenericControl URLParam;
URLParam.Attributes["value"] = URLTextBox.Text;
There are many other ways you can accomplish the same thing, with or without a client script block (which also isn't hard). Just read the .NET Framework SDK documents.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I understand what you are trying to say, but it doesn't seem to work as well. And yes, I really need to set the URL from the .cs file, because the combobox which I am using is a Web control, and it's only declared on the .cs file. I need that because I have to load an .ini file containing all information for the combobox. Do you have any solution to this?
cheers
|
|
|
|
|
If the control is declared as <cod>protected, your page can access it because the .aspx page derives from your code-behind page which (unless you've changed it) derives from the Page class. I've already given you several ideas, all of wich will work. You can declare the ActiveX control in the .aspx file and make the <param> tag an HTML server control and change the attributes. That would be the easiest way and would still give you access to the value attribute for the URL parameter so long as its declared as protected in your .cs code-behind file. I do something like that for our web site and it works fine.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks there, it's working
just one problem... sometimes after I rebuild the solution, the id and the runat attribute that i've declared in the URL parameter in the .aspx file are gone. Is it probably because they are generic controls? is there any way to keep them permanently?
Thanks for your help!
Cheers
|
|
|
|
|
Interesting. I'm not really sure why it'd do this. Is this just for the HTML server control that represents the PARAM tag? If it's for the OBJECT tag (which it shouldn't be, but just to show you what VS.NET sometimes does), VS.NET will treat objects differently. I've never seen this behavior for a generic HTML control, though.
It's not a compile issue, though, it's an editor issue. After all, VS.NET just runs the compiler on the source you have. I would check your HTML/XML editing options in VS.NET and play around with those a little.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
so do u want me to send the .aspx file? or the whole lot?
or is there any other way besides declaring HTMLGenericControl?
|
|
|
|
|
You could always make your own HTML server control like I mentioned before. It's really not that hard. Extend HtmlControl and override Render to output your code. Add a URL property to it that you can set and render in the output, something like:
public class HtmlParamControl : HtmlControl
{
public string Url
{
get { return (string)ViewState["Url"]; }
set { ViewState["Url"] = value; }
}
protected override void Render(HtmlTextWriter writer)
{
writer.WriteBeginTag("param");
writer.WriteAttribute("name", "URL");
writer.WriteAttribute("value", Url);
writer.WriteEndTag("param");
}
} ...or something similar to that. You really don't need to worry about anything else since a PARAM tag is very basic. It's possible that VS.NET is removing the ID and RUNAT attributes because they're not allowed on the PARAM tag so VS.NET probably thinks it's fixing the "problem". This way should work.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
so how do u use it?... for example if i want to set the url value of the windows media player from a textbox, do i just use:
protected HtmlParamControl params;
...
...
params.Url = TextBox1.Text;
is that it? or do I have to call the render method?
thanks a lot for the help
Cheers,
Rico
|
|
|
|
|
Read the documentation. First, Render is protected so just how do you plan on calling it from another class? Second, that method is called automatically to render your control. You override that to provide your own rendering but your method is called instead of the parent class's. That's how polymorphism works.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
how would i go about connecting a local drive to a network share in a console app? basically i want to simulate 'net use x: \\computer\share'
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
The easiest way is to just create a new Process with your arguments:
Process.Start("net.exe",
string.Format("use {0}: {1}", driveLetter, shareName)); The alternative requires much more work since you have to P/Invoke several native functions and create several structures in C#. If you'd rather do it this way, click "Search comments" above the message board and search for something like "net use". This has been covered a couple times in recent history.
Note, you can also modify the code above to include a username and password. Just type "net use /?" on the command prompt to learn more about the available switches.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i'm writing a console app to be used in dos mode on a boot disk. i want to clear the screen before i output a list of information. how do i clear the screen?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|