|
i want to set the connect string in webconfig file at run time.my sanrio is than when my web page load that server name read from note paid and than write in webconfig file'
is it possible?
<add key="dbcon" value="Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=RMS;Data Source=varServerName">
suahil shahab
|
|
|
|
|
well budy can't understand why you want to do this...
|
|
|
|
|
If you change the web.config file at runtime, the web application will be restarted.
What is it that you want to accomplish?
---
single minded; short sighted; long gone;
|
|
|
|
|
You can write... But when you change the web.config, the application will compiled again by MSIL by the ASP.NET. So all the sessions will be destoryed...
Example:
Dim config As System.Configuration.Configuration<br />
Dim appSetting As New System.Configuration.AppSettingsSection<br />
<br />
config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~")<br />
appSetting = config.GetSection("appSettings")<br />
<br />
'To add new key<br />
appSetting.Settings.Add("[KEY_NAME]", "[VALUE]")<br />
<br />
'To change exists key<br />
appSetting.Settings("[KEY_NAME]").Value = "[VALUE]"<br />
<br />
<br />
config.Save()
|
|
|
|
|
i want same code that u define. when i use this code it give error in
in following line plz guide me.i have imports System.configuraton
Dim config As System.Configuration.Configuration
Dim appSetting As New System.Configuration.AppSettingsSection
config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~")
appSetting = config.GetSection("appSettings")
suhail shabab
|
|
|
|
|
Can you tell me the Error please??
|
|
|
|
|
System.Configuration.AppSettingsSection is not define
|
|
|
|
|
Please post your code...
The error is not relevent to find the fact.
|
|
|
|
|
whenever web.config file changed the application starts again..
so first u have to find a way to change the web.config file without restarting the application
|
|
|
|
|
Hi ASP.net Lovers
Well budys if .Net Framework 3.0 is released then whats new specific for ASP.net??? Thanks for your time...
|
|
|
|
|
.NET 3.0 right now is the new name for WPF. What's new for the web is WPF/E, but it's not really part of ASP.NET.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|
|
You can combine ASP.NET with WF for a workflow-based site. Also you can have authentication based on Cardspace.
|
|
|
|
|
Hi Friends,
I need to have Click event for the Label control. Presently .NET 2.0 does not provide Click event for a label box.
I inherited the Label control and created my own control with Click event. But it not working.
Can anyone helping me? Gimme a example or reference if possible.
|
|
|
|
|
Venkatesh MookkanI inherited the Label control and created my own control with Click event. But it not working.
You should also inherit from the IPostBackEventHandler interface and implement the RaisePostBackEvent so that it raises your click event. Then add the following line to the control initialization:
this.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, this.ClientID));
|
|
|
|
|
szukuro wrote: You should also inherit from the IPostBackEventHandler interface and implement the RaisePostBackEvent so that it raises your click event.
I did this already...
szukuro wrote: this.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this, this.ClientID));
Here "Page" throws NullReferenceException. I have already tried it and removed it.
|
|
|
|
|
Venkatesh MookkanHere "Page" throws NullReferenceException. I have already tried it and removed it.
Have you tried it in a late event like OnPrerender? If you use this before the Control gets added to the a page, the Page property is null.
|
|
|
|
|
I am not saying about the Controls..
I am talking about the "Page".
You can try my code:
<DefaultProperty("Text"), ToolboxData("<{0}:EglLabel runat=server></{0}:EglLabel>"), _<br />
Description("Eagle Label")> _<br />
Public Class EglLabel<br />
Inherits Label<br />
Implements IPostBackEventHandler<br />
<br />
<br />
Public Event Click As EventHandler<br />
<br />
<br />
Protected Overridable Sub OnClick(ByVal e As EventArgs)<br />
RaiseEvent Click(Me, e)<br />
End Sub<br />
<br />
Public Sub RaisePostBackEvent(ByVal eventArgument As String) Implements System.Web.UI.IPostBackEventHandler.RaisePostBackEvent<br />
OnClick(EventArgs.Empty)<br />
End Sub<br />
<br />
Public Sub New()<br />
Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(Me, ClientID))<br />
End Sub<br />
End Class
|
|
|
|
|
Venkatesh MookkanPublic Sub New()
Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(Me, ClientID))
End Sub
End Class
That's the problem rigt here. Like I said, you try to attach the method too early. In the constructor the control has not been added to a page yet, thus the Page property is Nothing at this time. Later on in the control life cycle the controls will get added to a page, and the Page property will now contain a reference to this page.
So to make it work, insteas of Public Sub New() write Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
|
|
|
|
|
Its working... Thanks Man...
|
|
|
|
|
HI Venkatesh
How are you adding that Label to youe Aspx page ?
As its not a custom control ...
Where are you declaring this label in Aspx.cs file ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Sandeep Akhare wrote: How are you adding that Label to youe Aspx page ?
Hey Sandeep, I am not adding... I am inheriting the Label as MyLabel which has all the features of Label. In addition to that I am adding Click event to it.
Thats it...
It works fine...
|
|
|
|
|
Venkatesh MookkanI am not adding...
You are not adding this MyLabel to any aspx page ?
Actually after reading your post i found it intresting so i also started but
i am confused Can you post the whole code ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hey Sandeep,
I can't post the source since it is my Company's property. Its all about INHERITANCE.
Right example is, each CodeBehind of ASP.NET inherits from Page Class.
|
|
|
|
|
i have datagrid with paging (page no)
In that datagrid one column contains check box. can we make the checked state remains checked while traversing different pages in datagrid. how can i get the values of particular column which are in checked
give the answer for this in asp.net 1.1
m.ramesh
|
|
|
|
|
Use FindControl method and find the CheckBox using its name.
|
|
|
|