|
Hi,
I have the below code in my code-behind file.
protected string ConvertPercent(object number)
{
if (number == DBNull.Value)
return "-";
else
return String.Format("{0:F}", number);
}
Currently only negative numbers having '-' sign.
How can i make positive numbers having '+' sign?
Thx....
|
|
|
|
|
try
private static string FormatMyNumber(object Number)
{
float myFloat;
if (!float.TryParse( Number.ToString() , out myFloat))
return "ERROR";
if (myFloat < 0)
return string.Format("{0:F}" , myFloat);
else
return string.Format("+{0:F}" , myFloat);
}
There are most probably better ways, but it's too early for me at the moment...
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
|
deepaknigam11 wrote: SqlConnection con;
string str= ConfigurationSettings.AppSetting["Coonectionstring"];
con=new SqlConnection(str);
This looks fine. Have you checked the spelling ? Try printing str and check what you are getting over there
|
|
|
|
|
it is the same code i have tried to connect with the database.
Deepak Nigam
|
|
|
|
|
deepaknigam11 wrote: string str= ConfigurationSettings.AppSetting["Coonectionstring"];
Is it really coonectionstring, or is it ConnectionString?? (double o vs double n)
-------------------------------------------
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Just bugger off and leave me alone!!
|
|
|
|
|
Sorry dear
there is no meaning of o or n.
bcoz it is just the name of variable that i have taken in the web.config like this..........
<configuration>
<appSettings>
<add key="CoonectionString"
value="server=localhost;database=Northwind;uid=sa;password=secret;" />
</appSettings>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Deepak Nigam
|
|
|
|
|
I want to implement treeview in my asp.net 1.0 web application. The data for that will come up from sql database. But in my installed .net version it is showing treeview tool in toolbox but disabled.
So what can I do. can any one give me sample code for it.
Thanks!
|
|
|
|
|
I have a table in Master file like this;
<table border="0" cellpadding="0" cellspacing="0" WIDTH=500 height=100%>
<tr>
<td colspan="2" WIDTH=500 height=100> TITLE </td>
</tr>
<tr>
<td WIDTH=20 valign="top">
<table>
<tr>
<td WIDTH=20 HEIGHT=10> row1 </td>
</tr>
<tr>
<td WIDTH=20 HEIGHT=10>row2</td>
</tr>
<tr>
<td WIDTH=20 HEIGHT=100%>row3</td>
</tr>
</table>
</td>
<td WIDTH=480 height=100% VALIGN=TOP> ContentPlaceHolder</td>
</tr>
</table>
Problem: I want to change row3 height dynamically. How? For example; Row1 height is 10 and Row2 height is 10 so total 20px. If ContentPlaceHolder height is 100 so Row3 hight must be 80px. How can I do?
Best Regards...
|
|
|
|
|
First of all, you'd do well to make your code XHTL. This means putting quotes on all your attributes. Better yet, use css instead. If you make your values reference code behind varables, then they can be calculated.
width="<%=Width%>"
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
I am new to asp.net and C# and I just want to know what application servers are out there. I know there is IIS but are there any others. Also how much does IIS cost? or is free?
|
|
|
|
|
steven3311 wrote: I am new to asp.net and C#
The most important tool you have for learning new languages is google.
There are other servers, but I'm not sure which ones work with ASP.NET. IIS is built into higher versions of Vista and XP. I don't believe it's possible to buy it.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
Yes Google has been a big help for me throughout the years.
So IIS is an application server that is built into XP, Vista, and Win Server? I was just wondering if there was a price because i am trying to add up my production costs.
|
|
|
|
|
Correct. Not in XP Home and not in some of the lower end Vistas, but it's built in the XP Pro and the higher Vista's. It's with Windows Server, for sure.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillionOneHundredAndFortySevenMillionFourHundredAndEightyThreeThousandSixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it )
|
|
|
|
|
I'm working on a website project, and running it inside VS2005. When I try to do the following:
System.Configuration.Configuration rootWebConfig =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/MySite");
I get an exception that reads
(paraphrased)Problem loading config file: Failed to access IIS metabase.
It seems to work for everyone else here. How do I fix it?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Looks like a installation issue. Check this[^] discussion, check the last message, there is a workaround for this issue
|
|
|
|
|
This will of course give you the error as you are using the OpenWebConfiguration incorrectly. OpenWebConfiguration is a general purpose function that tries to open the web configuration of a specified virtual path. The Virtual path may not be same as the path of you application. If you specify a path other than null or empty OpenWebConfiguration tries to read the IIS metabase to figure out whether the particular site (/MySite) exists. Since you don not have IIS installed this fails.
From VS 2005 web development server you can only issue the following call (if you don't have IIS installed):
System.Configuration.Configuration rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null);
This is probably what you want anyway. The configuration for the current web site.
|
|
|
|
|
I'm trying to write an automated testing harness for a large web application ( ASP .NET 2.0 ).
I want to create a page within this application that will let the user choose from a list of all the web pages of the application ( listed by their page class names ) and then run the testing harness on the selected page class.
What I want the test harness to do, is basically loop through all the controls of the page and run pre-determined checks and tests on each control based on its control type (I.E. check if maxlength of textbox is set, etc. ).
I'm encountering two major problems. First, I cannot figure out a way to get at a list of all the page classes of my web application. Second, once I can actually create an object of a page class, I cannot initialize the object with all of the usual controls, thus, I can't run any tests on it.
Does anyone know how I can solve either of these two issues?
Any help would be greatly appreciated.
-Peter
|
|
|
|
|
I keep getting the error:
Could not load file or assembly 'Validators, Version=1.0.0.0' or one of its dependencies. The system cannot find the file specified.
I incorperated a dll as suggested by http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx[^]
It works locally, but on the server it can't find the DLL. I've triple checked, and it's on the server in the bin directory. Everything is set up exactly as it is locally. *shrug*
|
|
|
|
|
|
AJAX is installed. It's a problem with the validators dll specifically.
|
|
|
|
|
Let's be clear here, you're not installing AJAX, you're installing a library that uses AJAX.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Both. I'm using (or trying to use) a library that solved an issue I was having with the AJAX validator controls. I'm also using other AJAX controls.
|
|
|
|
|
|
nemo wrote: Or is there a better way to do this?
Whell, there is.
Use VS2005, and look in menu and find Publish Site or something.
Dont know where exactly, because i am not on my computer now.
|
|
|
|