|
My point is that instead of searching all the datasources on the web page to update their ConnectionString property, we only need to update the connection string in a central place and all the datasource controls using this place will benefit this change. Below is the sample code to demonstrate what I mean:
public class ExSqlDataSource : SqlDataSource
{
public override string ConnectionString
{
get
{
return base.ConnectionString;
}
set
{
string conString = HttpContext.Current.Items["MyConnecionString"] as string;
if (string.IsNullOrEmpty(conString))
conString = value;
base.ConnectionString = conString;
}
}
}
In the example above, I use the HttpContext.Current.Items to store the connection string (you can use whatever you want), this custom sqldatasource control can be used on the web page in lieu of the built-in sqldatasource control as below:
<cc1:ExSqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="..."></cc1:ExSqlDataSource>
At runtime, the datasource control by default uses the connection string stored in the ConnectionStrings section of the web.config file under the key NorthwindConnectionString . If I want to dynamically replace this connection string, I simply set it in the HttpContext.Current.Items["MyConnecionString"] item in the web page:
public partial class Default_ : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
HttpContext.Current.Items["MyConnecionString"] = "new connect string goes here";
}
}
So all custom datasource controls declared in the web page will benefit this new connection string without requiring you to set their ConnectionString property.
In addition, there is also another extention point that you can use to change the default connection string. That is you can build your own expression builder and you can use your own expression to set the ConnectionString property of the datasource control. With this option, you can intervene the way the ASP.NET sets the ConnectionString property of the datasource control. For more details, you can check out the article[^].
|
|
|
|
|
Thanks a lot !!! I'll see what i can do. The problem is that our application has over 200 page. So when they ask us to allow users to be able to select a database (which was impossible before) i've searched a solution where i will not have to change all the pages. That's why i added a function in our masterpage to search for all the datasource and then update the connectionString.
Now i realize that it was not a good idea.
Thanks again !
|
|
|
|
|
I have a wizard control in my .net 2.0 page. I ran into a problem in which clicking on "Previous Button" will result in an error message: The command 'MovePrevious' is not valid for the previous step, make sure the step type is not changed between postbacks.
Also clicking on the "Finish Button" will result in an error message: The command 'MoveComplete' is not valid for the previous step, make sure the step type is not changed between postbacks.
However, the "Next Button" works without any problem.
My first wizard page has StepType="Start"
Second wizard page has StepType="finish"
Last wizard page has StepType="Complete"
I have not done any fancy stuff to the control, but I cannot get the button click to work.
Rookie Programmer
|
|
|
|
|
You may want to debug your code and have a look at some properties of the Wizard control like ActiveStepIndex, WizardSteps. Btw, how do you define the wizard control? declaratively or dynamically?
|
|
|
|
|
Hi, How I can set direction of SiteMapPath to "right to left" in ASPNET2?
Thanks.
|
|
|
|
|
|
Thank you very much minhpc_bk.
|
|
|
|
|
Hello,
I am loading a xml file as follows:
docXML.Load(server.MapPath("MyFile.XML"))
Instead of using server.MapPath("MyFile.XML") to select the XML file to use I want to use the same file which is defined in the sitemap provider "SiteMapProvider".
<providers>
<clear/>
<add
name = "SiteMapProvider"
siteMapFile = "~/MyFile.sitemap"
type = "System.Web.XmlSiteMapProvider" />
Is this possible? How can I do this?
Thanks,
Miguel
|
|
|
|
|
|
i`ve used the following code while uploading a .csv file
if(pFileObject.PostedFile.ContentType.ToString() == "application/octet-stream")<br />
{<br />
throw new Exception("Please close the file you want to upload and then try again.");<br />
}
it works fine in my machine, but in other machines it works just opposite, i mean when the file is open it gives the error message but when it is closed it uploads successfully, but for other machines it works just opposite, and in other machines when uploading the .csv file it always returns content type as "application/octet-stream".
good suggestions are welcome
|
|
|
|
|
Hi,
My ASP.NET application is hosted on Windows 2003 Standard Server with IIS6.0. My
application dynamically converts the autocad files to PDF when user request it, For this i
am using third party command line tool which accept input file path and output file path and
i am calling this exe using [B][I]Shell()[/I][/B] method. Evetything is working fine on
development machine which is windows 2000 pro. But when i run the same on server seems like
thigs not working,Is it related to any security settings of IIS.
(I also set the application Execute permission to Script and Executable but no luck....
:ehh: )
If you can provide any thread it would be help full.
Regards,
Ritesh N. Jain
|
|
|
|
|
Hi there,
How do you run the executable from the ASP.NET? You are using the Process class? You might want to check out this document[^].
|
|
|
|
|
Hi,
thanks for reply.I tried with both Process class as well as with Shell() but no luck, when i call the process it runnning in task manager but generate no o/p file.......
Regards,
Ritesh
|
|
|
|
|
You might want to check the account under which the spawned process runs in the Task Manager to see if it has enough permission to do the task.
Another option you can try is that you can implement a window service which is responsible for running the third application. The ASP.NET application can use the .Net Remoting to simply send a request to the service to have it run the application.
|
|
|
|
|
hi,
the third party is running under local service account (same as w3w ) and i set full control for this account for exe as well as for web app, i don't have much idea about remoting but i will try to it,
Thankx,
Ritesh
|
|
|
|
|
Hi I am having trouble with an asp.net panel on my c# project when I do a postback to save certain info on the page my list of 16 dropdown lists in the panel all lose their selected values so I am just wondering if anyone knows why this is happening or how to prevent it from happening thanks in advance
Tim
|
|
|
|
|
did you fill ddls inside !Page.IsPostBack ???
|
|
|
|
|
yes i did that but i have actually just realised that i was wrong with what i thought was the problem as the ddls dont lose their values they are filled a second time and so are set back to the first ListItem. so my problem now is how do stop an event from bein fired when i save the first values.
the page has a User Control on it and i need to fire an event when a item is selected on a ddl so i attached an event handler to the ddl
//*** attach handler to ddl match
SelectSeasonCountryCompTeamMatch1.MatchChanged += new System.EventHandler(this.match_SelectionChanged);
but when i press the save button this function match_SelectionChanged is executed again and the values they are filled a second time. i wud apreciate any advice on this problem thanks
|
|
|
|
|
is it possible setting read/write permissions on System.Windows.Forms.Clipboard for reading/writing data on clipboard
|
|
|
|
|
|
How to get a selected value from Grid view and what are the properties i have to set in the aspx page for the checkbox field
-
|
|
|
|
|
you can get many examples related to gidview
Here[^].
Best Regards,
Apurva Kaushal
|
|
|
|
|
Fetching location of 5 Km Distance from google map based on zip code or pin code and retriving the value back to the web form.
I am using Google Web service.It is showing the error of Invalid key .
The code as follows:
Dim ProxyHost As String = "192.168.0.100"
Dim ProxyPort As Integer = 8080
Dim ProxyUser As String = ""
Dim ProxyPassword As String = ""
Dim ProxyDomain As String = "http://api.google.com/search/beta2"
Dim oWebProxy As System.Net.WebProxy = New System.Net.WebProxy(ProxyHost, ProxyPort)
oWebProxy.Credentials = New System.Net.NetworkCredential(ProxyUser, ProxyPassword, ProxyDomain)
' obj_wrr.Proxy = oWebProxy
'obj_wrr.Credentials = New System.Net.NetworkCredential(feedid, password)
Dim s As localhost.GoogleSearchService = New localhost.GoogleSearchService
s.Proxy = oWebProxy
Dim r As localhost.GoogleSearchResult
r = s.doGoogleSearch("", TextBox1.Text, 0, 10, False, "", False, "", "", "")
Dim strFile As String = "C:\\result.html"
Dim sw As StreamWriter = File.CreateText(strFile)
sw.WriteLine("" & Microsoft.VisualBasic.Chr(9) & "BODY { font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; font-size : 9pt; color : #000000; SCROLLBAR-FACE-COLOR: white; SCROLLBAR-HIGHLIGHT-COLOR: #003366; SCROLLBAR-SHADOW-COLOR: #003366; SCROLLBAR-3DLIGHT-COLOR: #f9f9f9; SCROLLBAR-ARROW-COLOR: #003366; SCROLLBAR-TRACK-COLOR: white; SCROLLBAR-DARKSHADOW-COLOR: #f9f9f9 }")
For Each dc As localhost.DirectoryCategory In r.directoryCategories
sw.Write("Category : ")
sw.WriteLine(dc.fullViewableName)
sw.WriteLine("
")
Next
For Each re As localhost.ResultElement In r.resultElements
Dim strTitle As String = "" + re.title + " "
sw.WriteLine(strTitle)
Dim strSnippet As String = re.snippet + " "
sw.WriteLine(strSnippet)
Dim strLink As String = "" + re.URL + " - " + re.cachedSize + "
"
sw.WriteLine(strLink)
sw.WriteLine("
")
Next
sw.Close()
Label1.Text = TextBox1.Text + " 's web search"
Dim estResults As Integer = r.estimatedTotalResultsCount
Dim ldTime As Double = r.searchTime
Label1.Text = "Total " + Convert.ToString(estResults) + " " + "1 - 10 seach result Total time:" + Convert.ToString(ldTime)
Dim obj As Object = Nothing
Dim di As DirectoryInfo = New DirectoryInfo(Environment.CurrentDirectory)
Dim strFilePath As String = di.FullName + "\" + strFile
WebBrowser.Navigate(strFilePath, obj, obj, obj, obj)
-- modified at 5:42 Friday 20th October, 2006
|
|
|
|
|
Hello,
I'm developing a web application, and at the beginning, I've put a login box in the main window. From this window, users will be redirectionated to different interfaces depending on their profiles. If you are the root, you will be send to a window with different options than if you are a visitor.
I know how to do this in Java (struts), with profiles, but I don't know how to do it in .NET.
Is there somebody who can help me?
Sorry if you don't understand correctly my English .
|
|
|
|
|
create on table in database, having to columns.........namely
1. User_ID
2. Url_Path(Specify path of the .aspx page here)
So that, through this table u can get the url for that particular user,
So after getting Use_ID from login page, u can easily redirect that user to the respective Url.
Try it out.
May be it will solve ur problem.
|
|
|
|