|
Hi,
I have created an application running on ASP.Net using C#. I have a panel and a button to print the page.On click of button content of the panel should be printed and not other part of page. Can anyone help me on this, please?
Thank u.
kamalnath
|
|
|
|
|
exactly waht i want to do i want to check that whether a particular string is in the string or not?
like
str ="C:\Inetpub\wwwroot\medicaps";
now i want ot check whether a wwwroot is in this string or not.
thanx
|
|
|
|
|
Perhaps you would like to listen to the advice given on your last post before asking the same question again.
only two letters away from being an asset
|
|
|
|
|
I know C++ had a string compare function, If if available in .Net dont know
|
|
|
|
|
Hi here is the way, we can use "IndexOf" string class method.
string strTest = "I am strong";
if(strTest.IndexOf("strong")==0) { return(false); }
Ram
|
|
|
|
|
Using IndexOf will work but the System.Text.RegularExpressions is a better way, here is an example.
<br />
Private Function InLine(ByVal Line As String, ByVal Value As String) As Boolean<br />
Dim r As Regex = New Regex(Value, RegexOptions.IgnoreCase)<br />
Dim m As Match = r.Match(Line)<br />
If m.Success Then Return True Else Return False<br />
End Function<br />
|
|
|
|
|
Why not just use .Contains()?
|
|
|
|
|
To the best of my knowledge .Contains is not available to string variables. It is for ArrayList and other Collection objects. If this is wrong could you please show me an example?
|
|
|
|
|
|
Will do nicely. It's only available in framework 2.x.
---
b { font-weight: normal; }
|
|
|
|
|
If you need the added functionality that the regular expression offers, it's a better way. If you don't, the IndexOf way is more efficient.
You forgot to escape the value, by the way. And I really don't see the reason to check the value of Success before returning it...
Private Function InLine(ByVal Line As String, ByVal Value As String) As Boolean
Dim r As Regex = New Regex(Regex.Escape(Value), RegexOptions.IgnoreCase)
Dim m As Match = r.Match(Line)
Return m.Success
End Function
---
b { font-weight: normal; }
|
|
|
|
|
I'm still working with 1.1 so that is good to know when I move to 2.0 – thank you. I see your point with using the IndexOf and agree it will provide better performance then the function.
|
|
|
|
|
How do I access a web.config from my web service
I need to grab the connection string of one of many data basis
Regards
|
|
|
|
|
Access it the same way you normally would, ConfigurationManager.ConnectionStrings
only two letters away from being an asset
|
|
|
|
|
Sorry I'm lost here
Bit more info please
Regards
|
|
|
|
|
This What I have done It works fine But I need to get only the one from the default web.config file.
Dim the_string_final As String = ""
Dim the_string_temp As String = ""
Dim counter As String = 0
Dim connectionStrings As ConnectionStringSettingsCollection = _
WebConfigurationManager.ConnectionStrings
Try
Dim connectionStringsEnum As IEnumerator = _
connectionStrings.GetEnumerator()
Dim i As Integer = 0
While connectionStringsEnum.MoveNext()
Dim name As String = connectionStrings(i).Name
Debug.WriteLine(name)
Debug.WriteLine(connectionStrings.Item(i).ConnectionString)
counter = counter + 1
the_string_temp = "****Number: " + counter + " '" + connectionStrings.Item(i).ConnectionString + "'" + "NAME: " + name
the_string_final = the_string_temp + the_string_final
i += 1
End While
Return the_string_final
Catch ex As Exception
End Try
Return the_string_final
The output:
<string xmlns="http://spero.co.za/">****Number: 2 'Data Source=(local);User ID=sa1'NAME: SL2010WSConnectionString****Number: 1 'data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true'NAME: LocalSqlServer
|
|
|
|
|
I Have tried this as well and no luck
Dim rootWebConfig As System.Configuration.Configuration
rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Nothing)
Dim connString As System.Configuration.ConnectionStringSettings
If (0 < rootWebConfig.ConnectionStrings.ConnectionStrings.Count) Then
connString = rootWebConfig.ConnectionStrings.ConnectionStrings("MyString")
If Not (Nothing = connString.ConnectionString) Then
Console.WriteLine("Mystring = {0}", connString.ConnectionString)
Else
Console.WriteLine("Mystring")
End If
End If
|
|
|
|
|
WebConfigurationManager.ConnectionStrings["Default"].ToString()
only two letters away from being an asset
|
|
|
|
|
Hi Mark
Will try.
|
|
|
|
|
Hi Mark
This works
Dim the_string_final As String = WebConfigurationManager.ConnectionStrings("SL2010WSConnectionString").ToString()
Thanx
Ok now next question, How do I edit this field in the web.config file?
|
|
|
|
|
HI
I tried this
Dim Config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration("/SL2010WS")
Dim csSettings As New ConnectionStringSettings("SL2010WSConnectionString", new_string)
Dim csSection As ConnectionStringsSection = Config.ConnectionStrings
csSection.ConnectionStrings.Clear()
Config.Save(ConfigurationSaveMode.Modified)
Return (new_string + " was saved to web.config")
As soon as I try to save the file then the VS tells me I do not have access to this file.
I checked but the file is not read only
|
|
|
|
|
My web service[say, webmethod startstoptheservice()] and my windows service[say Service1] both reside on the same machine.
I am creating another web application(residing on a different web server) that will access the webmethod startstoptheservice() to monitor(start/stop/restart) the service1.
[I am able to monitor the service1 from a windows application.]
But when i try to do the same using above mentioned method some error message saying access not granted is displayed.
A part of the error message includes:
System.ComponentModel.Win32Exception: Access is denied --- End of inner exception stack trace --- at System.ServiceProcess.ServiceController.GetServiceHandle(Int32 desiredAccess) at System.ServiceProcess.ServiceController.Stop() at HPClient.ServicesAgent.StartStopTheService() in....
Is the solution i am envisioning to monitor a windows service remotely really possible...? What may be the possible solution to the problem i am having at present.Any ideas/suggestions/comments or pointers would be appreciated.
rabindra
|
|
|
|
|
Yes, Use WMI. This is simple and you can do all task which you can do it window console. Infact you can fire queries also.
Amit
|
|
|
|
|
Hi,
I need your suggestion, I have created an Windows service to mointer my mail id, it stores the content of the mail in the data base. I want to install my service in an remote system. I dnt know how to do it.
Plz suggest me how to install it in remotew machine........
Thanks in advance
Bye
Exelio
Know is Drop, Unknown is Ocean
|
|
|
|
|
i want to find a substring from a string.
like i have a string
str ="/abc/xyz/sdg/"
and i want to find "xyz" then could i achieve this
thanx
|
|
|
|