|
|
Hi..
I want to access ConfigurationManager.AppSettings["xxx"] value to session_end event of global.asx.
Is it possible ? As I am not getting the value there.
thanks
By:
Hemant Thaker
|
|
|
|
|
Hemant Thaker wrote: Is it possible ?
Yes.
What problem are you getting ?
Below is my web.config entry.
<appSettings>
<add key="k" value="123"/>
</appSettings>
Here is my Session_End Code.
void Session_End(object sender, EventArgs e)
{
string myval = ConfigurationManager.AppSettings["k"].ToString();
}
On Session_End , I am getting value myval=123.
|
|
|
|
|
Session end has nothing to deal with ConfigurationManager.
ConfigurationManageris a static class that Reads different section of ASP.NET config file and gives you the data.
I think it should be accessible from anywhere, even from Application_end.
There might be some other issue with it, it is nothing to deal ConfigurationManager.
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
Hello I would like to show the edited text of the FCKEditor along with the pictures in a DIV tag, am I able to do that or no? if yes please help me to do so.
I have implemented the FCKEditor and it is working ok, I have uploaded the example (FCKEditor ready) code already, you can download it from here[^]
thank you in advance
|
|
|
|
|
u can also try Freetextbox it is very good as compared to the fck i m using this
<a href="http://freetextbox.com/default.aspx"></a>
thanks,
amit
|
|
|
|
|
Dear Amit, thank you for the reply but my problem is in showing the HTML code that is generated by these component in the page. I don't know how and where I can show them(in a DIV tag?).
|
|
|
|
|
Hi.
I am fairly new to asp.net, and have a problem with a page I am working on. The page contains some textboxes, and a button. When the button is clicked, the codebehind fetches the textbox contents. If the user did something wrong, he is redirected to the same page again, but before that the textbox contents is saved in the session. When the page loads again the textboxes are now filled with this sessiondata so the user doesent have to input all the data from scratch again. But when the button is clicked the second time, the textbox content I read is the old content, and not the new data the user has typed in. How come?
To make my problem a bit easier to understand:
1. Page loads
2. User types "John" in the name textbox, and fills out other textboxes
3. User clicks the submit button
4. Codebehind reads "john" from the name textbox
5. Codebehind registers an error from the other stuff the user has filled in, and redirects to the same page with all textbox contents saved in session
6. Page loads, and all textboxes are filled from the session data
7. User changes the text in the name textbox to "Joe"
8. User clicks submit
9. Codebehind reads "john" from the name textbox - How come?!
Really hope you can help me understand this!
Thanks alot 
|
|
|
|
|
It should not happen.Might be the case when user changes the data in the textbox and click submit then on pageload you are again filling the data from session.Debug the code and check the values in immediate window you might the get the issue.
One more thing, why you are taking the help of session, you can use viewstate.Enable the viewstate of the contrls on the page that will suffice your requirement.
|
|
|
|
|
Brij wrote: One more thing, why you are taking the help of session, you can use viewstate.Enable the viewstate of the contrls on the page that will suffice your requirement.
Relation of textbox and ViewState is something different with respect to other controls. If you make EnableViewState=False; for Textbox, still it will maintain the postback data. Why ?
First of all you need to know what actually happened during ASP.NET Page life cycle and ViewState .
In the ASP.Net page life cycle, two events related with View State.
1. Load View State : Where view state data is loading for the control and which happened before Page_Load.
2. Save View State : Where control data store in a hidden field before the Page_Render.
Now, If you disable the ViewState for the control it should store the view state data but, you are saying in Textbox, after you disabled the view state , control holds the data after postback,
Here is the Trick, There is another event fired during Page Life Cycle, which is, Load PostBack Data
ASP.NET controls which implement IPostBackEventHandler will load its value from the appropriate postback data. This value is not read from view state but from Postback From and this is true for those control which implements the IPostBackEventHandler and TextBox is one such control.
Hope you got my point.
|
|
|
|
|
You are right Abhijit. But Load PostBack Data is called only for input controls those implement IPostBackEventHandler . For rest of the controls, viewstate could be used.
Thanks for adding it in detail.
|
|
|
|
|
lvq684 wrote: Really hope you can help me understand this!
can you Please show us the code block ?
|
|
|
|
|
Thanks alot for all your answers.
I´ve tried with the viewstate, but It didnt really work. It prolly would have if I tried for a longer time
Instead I found out that the page load method is called several times, even if the page isnt loaded. So in that way the old values were set.
But how come the page_load method is called often, even if the user hasnt done anything on the page?
Thanks again 
|
|
|
|
|
Hi All,
I am converting HTML to PDF using itextsharp.dll. My HTML conatins table and
many rows. When a row goes to next page, its cells data is not shown in pdf
document. Initially, I fixed it by changing top and bottom margins. But it
caused problem in other cases. Note that I am getting HTML from user
control. When I copy this HTML in htm file, It shows all the data correctly.
But in pdf it does not show.
Any help?
Thanks,
Pervaiz Niazi
|
|
|
|
|
hi, iam using asp.net with c#
when iam trying to execute this querry iam getting error
can you correct my querry
SqlCommand cmdallltransactions = new SqlCommand("SELECT SUM(Amount)FROM AllTransactions WHERE (TransCode <> 0) GROUP by BranchKey="+Convert.ToInt32(Session["BranchKey"])+"", con);
con.Open();
txttotal.Text = Convert.ToString(Convert.ToInt32(cmdallltransactions.ExecuteScalar()));
con.Close();
error iam getting is
Incorrect syntax near '='.
|
|
|
|
|
SELECT SUM(Amount)
FROM AllTransactions
WHERE (TransCode <> 0)
AND BranchKey = 'branchkey'
You should also look at parameterizing your query.
|
|
|
|
|
i have created drop downdownlist and i m binding it with the testnames in the database.
Private Function load_sptestreqtestnameddl()
Dim Adptr As New SqlDataAdapter
Dim Pkgddldt As New DataSet
'################## FOR CONNECTION ################
Dim MySearchCon As DbConnection = providerFactory.CreateConnection()
MySearchCon.ConnectionString = connectionString.ConnectionString
'################### END OF CONNECTION #################
Dim str As String = Nothing
str = ("SELECT test_id, test_name FROM TestName")
Adptr = New SqlDataAdapter(str, MySearchCon)
Adptr.Fill(Pkgddldt)
sptestreqtestnameddl.DataSource = Pkgddldt
sptestreqtestnameddl.DataSource = Pkgddldt.Tables(0)
sptestreqtestnameddl.DataTextField = Pkgddldt.Tables(0).Columns("test_name").ColumnName.ToString
sptestreqtestnameddl.DataValueField = Pkgddldt.Tables(0).Columns("test_id").ColumnName.ToString
sptestreqtestnameddl.DataBind()
Return 0
End sub
the code shows me following error....this exactly same code works perfect in other webforms.
'sptestreqtestnameddl' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value
|
|
|
|
|
hi,
After filling the data adapter, please clear the dropdown then try to bind.
sptestreqtestnameddl.Items.Clear();
Seems to me after binding list, dropdown tries to select a value that is not even in the dropdown list.
Thnaks
|
|
|
|
|
Just specify columns in DataTextField and DataValueField like this:
sptestreqtestnameddl.DataTextField = "test_name"
sptestreqtestnameddl.DataValueField = "test_id"
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Hi, I'm writing a control of the dynamic in a
existing page is added.
You gotta think of a content management system, to a already
existing page will be added a User Control.
In this Usercontrol is used an UpdatePanel and ModalPopup.
To use these elements I need a script manager
I can not add an the Script Manager to my UserControl even one already existing Page in the CMS in my control will be added??
Are there any opportunities?
I hope you understand what I mean ....
Regards
|
|
|
|
|
If I understood you correctly, you're asking if only one ScriptManager per Page is allowed.
Yes, there can be only One.
I usually solve the problem by using a masterpage with a scriptmanager.
Don't insert the sriptmanager in your control, only the updatepanel(s).
Further reading : http://msdn.microsoft.com/en-us/library/bb398864.aspx[^]
Cheers
I don't like my signature at all
|
|
|
|
|
But how shoul i use a Master page if i write a Usercontrol who can be added in a Page?
I understand you wrong or just what?
So according to your proposal, it would mean that I have in my control in a MasterPage and who is my Script Manager?
Where shall I find my ModalPopup and update panels?
|
|
|
|
|
You don't need to change your usercontrol, just don't put a scriptmanager in it.
If you create a masterpage in your site which has a scriptmanager on it, you can drop or create your usercontrol on any page the has that masterpage.
It's a design issue :
- if a usercontrol has a scriptmanager on it, you can only put it in a page once.
- if you put the scriptmanager on a (content)page, there can be no usercontrols that have a scriptmanager.
- if you want to put your usercontrol on more than one page, you have to put a scriptmanager on every page that uses it.
Does the term "Webpart" mean anything to you? What you are trying to do sounds a bit similar to me.
Cheers
I don't like my signature at all
|
|
|
|
|
I have heard of but have not used it yet why?
I can not use MasterPage because the design is already given!
Its look like this in our cms
So Imagine somebody can add my Control right now into the Page(Template)! So This Page is already present with a Scriptmanager.
Klick ME
|
|
|
|
|
Ok, then go for the page, just DON'T put a scriptmanager in your own usercontrol.
It is an option to check in your code if a scriptmanager exists, if it doesn't then create it, before your ajax controls (ie UpdatePanel(s)) are loaded.
Cheers
I don't like my signature at all
|
|
|
|