|
Found it... HttpContext.Current
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
How can I access the control in the Master page from a class?
The master page has a label Label1 and am trying to access it from a web page.
(Label)Page.Master.FindControl("Label1"); It works on web page but same thing does not when I write it in a class in the application.
Please help
------------------------------------------------------------
"The only true wisdom is in knowing you know nothing." --Socrates
|
|
|
|
|
The following line of code will get a reference to the current page:
Page page = HttpContext.Current.Handler as Page;
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi All,
I'm having some difficulties and am hoping for some help. I have a site on one of our server used just for web services that I plan to use in other sites on that server. The web service site has been deployed to the server and seems to be working fine. When I call one of the services form my development machine it works fine, but now that I have used one of the services in finished site on that same server I am getting the following error.
Server Error in '/' Application.
--------------------------------------------------------------------------------
The request failed with HTTP status 400: Bad Request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The request failed with HTTP status 400: Bad Request.
Source Error:
Line 98: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://exaservice.net/WebServices/SearchSiteHtml", RequestNamespace="http://exaservice.net/WebServices", ResponseNamespace="http://exaservice.net/WebServices", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 99: public string SearchSiteHtml(string url, string webSearch) {
Line 100: object[] results = this.Invoke("SearchSiteHtml", new object[] {
Line 101: url,
Line 102: webSearch});
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\cc6d9c2e\63ba5077\App_WebReferences.9hwc9vsl.0.cs Line: 100
Stack Trace:
[WebException: The request failed with HTTP status 400: Bad Request.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +533252
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204
net.exaservice.www.SiteSearchWS.SearchSiteHtml(String url, String webSearch) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\cc6d9c2e\63ba5077\App_WebReferences.9hwc9vsl.0.cs:100
Search.Page_Load(Object sender, EventArgs e) in D:\websites\centralfloridafair\html\Search.aspx.vb:10
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
I just doesn't make since to me that it would work fine on my dev machine, but not in production. I have taken the following steps to trouble shoot.
Since both sites are on the same server I made sure I could ping the web service url from the server. That works fine. Just in case I modified the host file using the Loop back ip 127.0.0.1 to make sure. Still no good.
I have been reading some articles on line and one said that you should not have charters like _ in you service name, so I removed the _. Still no good.
Not too sure what to do. Any help is greatly appreciated.
-Adam N. Thompson
|
|
|
|
|
Hello,
Is there any possiblity in Asp.Net to create transparent gifs without unsafe code?
Is it possible to turn on complination with unsafe code in VS Express?
I have tried to put in following in my web.config, but it doesn't work
<br />
<compilers><br />
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="1" compilerOptions="/unsafe" /><br />
</compilers><br />
I know that it is possible to put it in machine.config, but on my hosting I am not able to access this file.
|
|
|
|
|
Hi,
I new started with Linq and VS2008 and created a new Web-App automatically with DataContext and LinqDataSource, GridView and DetailView.
But, because I want to place the var LinqQuery into the CodeBehind-File, I code the Var LinqQuery by hand and not by designer.
It works well inside GridView and DetailView for New, edit, Delete and Paging.
But for Sorting I find no way to use SortExpression and SortDirection inside var LinqQuery
private string GridViewSortDirection{
get{return ViewState["SortDirection"] as string ?? "ASC";}
set{ViewState["SortDirection"] = value;}
}
private string GridViewSortExpression{
get{return ViewState["SortExpression"] as string ?? string.Empty;}
set{ ViewState["SortExpression"] = value;}
}
protected void gvMain_Sorting(object sender, GridViewSortEventArgs e)
{
GridViewSortExpression = e.SortExpression;
GridViewSortDirection = e.SortDirection.ToString();
int pageIndex = gvMain.PageIndex;
CorydorasDataContext db = new CorydorasDataContext();
var FiArtsQuery = from p in db.FiArts
where p.Name.StartsWith(txtSuch.Text)
// orderby p.SortEspression SortDirection
orderby p.Name descending xxxxxxxx hier are the problem
select p;
gvMain.DataSource = FiArtsQuery;
gvMain.DataBind();
gvMain.PageIndex = pageIndex;
}
I hope anybody can help me?
Thanks
Rudolf
|
|
|
|
|
hi friends,
1)I have designed .aspx page in which user input the values.
2)when i click the save button, after that the save button should not be visible.
3)Whatever be the design of the .aspx page with values is to be saved as pdf file.
Now My problem starts from here,
I have used itextsharp.dll for creation of pdf files at runtime in asp.net but i don't know how to solve this problem with the help of itextsharp.
i have used many dlls which can be used for .aspx to .pdf conversion on fly but they are not working properly. For Example:PDFizers,ABC pdf,Ntidy,Ghtmldoc.exe etc....
as per my knowledge about itextsharp.dll, it create pdf file but the designing of the page is not possible with this..(if i am wrong then correct me..)
so what i have to do tell me about this....following is my code of creating pdf file by using itext sharp.
if any suggestion please reply,
all reply appreciated.....
thanks in advance.............
Private Sub function1()
Dim mydoc As iTextSharp.text.Document
Dim str As String
Dim a As PdfWriter
Dim ms As FileStream
cmdSave.Visible = False
str = Server.MapPath("bin\1.pdf")
mydoc = New iTextSharp.text.Document
If File.Exists(str) Then File.Delete(str)
ms = New FileStream(str, FileMode.OpenOrCreate)
mydoc.Open()
mydoc.Add(New Paragraph("123"))
mydoc.Add(New Paragraph("123"))
mydoc.Add(New Annotation("123", "123"))
mydoc.Close()
End Sub
modified on Thursday, December 20, 2007 5:41:55 AM
|
|
|
|
|
hello
i want to register some javascript file in my web page that not available for others
before ..
1- i create resource file in app_GlobalResources document
2 and in the load_page event i write
<br />
Dim scriptname As String = "script_Name.js"<br />
Dim Metype As Type = me.GetType()<br />
Dim cs As ClientScriptManager = Page.ClientScript<br />
cs.RegisterClientScriptResource(Metype, Scriptname)<br />
and in the end of page i write....
<br />
<script language="javascript">Function_Name();</script><br />
and i call any function that i define in script_Name.js file
i have (Object expected) error in page but when i register script file as Included dont have error
please help me
what is wrong....?
|
|
|
|
|
Not sure what your problem is... I use the following.
public void AddJavascript(string javascriptUrl)<br />
{
HtmlGenericControl script = new HtmlGenericControl("script");<br />
script.Attributes.Add("type", "text/javascript");<br />
script.Attributes.Add("src", ResolveUrl(javascriptUrl));<br />
this.Page.Header.Controls.Add(script);<br />
}<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
AddJavascript("~/Scripts/ImageRight.js");<br />
}
I didn't get any requirements for the signature
|
|
|
|
|
thank mr ToddHileHoffer
but...
i can register javascript file as include file
but i want register javascript file as webresource
in my post i say when i used included file i can call function
but when i register as webresource i cant call any function
but thanks for your attention
|
|
|
|
|
Well then all I can say is to try FireBug in FireFox. It might help you figure out why the object is missing. Not sure that's worth your time since you already have a working solution, but that is what I would do.
I didn't get any requirements for the signature
|
|
|
|
|
Guys,
We've spent the entire day looking at why our code kept open several Oracle socket connections on the web server. After a while, we saw that the .Close function was almost never called. Yeah, we thought, this is it. So I made a quick and dirty ASP.Net page with the proper dll's, a button that opens the connection and one that closes it... The socket stays open...
Earlier that day a colleague recommended to use GC.Collect(), which we tried in the Global.asax file (at Session_end). It didn't work. Now, just to make sure, I tried also a GC.Collect() right after the Close (so in the button event handler)... Lo, the socket connection dissappears. Move the GC.Collect() to the Global.asax; no avail anymore...
So why doesn't it work in Global.asax and it does work in the Page itself? (I also tried to put the connection in a Session variable, but that didn't work either)
thanks.
|
|
|
|
|
Instead of calling GC.Collect, you might want to use a 'using' structure:
using (conn = new SqlConnection())
{
}
On leaving the using block, dispose is called on the connection, which should free up any used resources.
|
|
|
|
|
good idea, but as it is an old website (not written by me ) I will not run through 20 000+ lines of code to check for using . Besides, the original coder opened stuff in one function and used it in another one .
but thanks though, I appreciate the effort
|
|
|
|
|
V. wrote: We've spent the entire day looking at why our code kept open several Oracle socket connections on the web server. After a while, we saw that the .Close function was almost never called. Yeah, we thought, this is it. So I made a quick and dirty ASP.Net page with the proper dll's, a button that opens the connection and one that closes it... The socket stays open...
This does't make sense...
You open the connection during the first postback. If you do not close the connection during that same postback, it is going to remain open. I don't see how you could close the object from the code of another button. ASP.Net does not work that way.
So if your application is leaving the connection open after a postback, you have to go back and fix the code. All 20,000 lines of it.
Calling the garbage collector is not going to do anything for you...
I didn't get any requirements for the signature
|
|
|
|
|
ToddHileHoffer wrote: If you do not close the connection during that same postback, it is going to remain open.
Please explain... I find this hard to believe
If I do:
CON.Open(...); in one function. Do some stuff with it and after eg. leaving the page and doing CON.Close();
it doesn't close?
This seems very hard to believe, ESPECIALLY if I would put my CON object in a Session object??
Now you got me confused...
ToddHileHoffer wrote: So if your application is leaving the connection open after a postback, you have to go back and fix the code. All 20,000 lines of it.
It's just a little more complicated than telling my boss, look, I know it has to be fixed tonight, but we'll have to rewrite it, so please wait a couple of weeks...
Besides, I'm telling my boss we should re-write it for months now.
|
|
|
|
|
V. wrote: Please explain... I find this hard to believe
If I do:
CON.Open(...); in one function. Do some stuff with it and after eg. leaving the page and doing CON.Close();
it doesn't close?
This seems very hard to believe, ESPECIALLY if I would put my CON object in a Session object??
Now you got me confused...
When you put an object in session, the code is being serialized into xml.
The object is recreated on each postback.
For example
<br />
plubic class TryToPutMeInSession<br />
{<br />
<br />
public TryToPutMeInSession ()<br />
{<br />
}<br />
<br />
}<br />
<br />
Anything that is not disposed of after the postack will stay in memory until the aspnet worker process (aspnet_wp.exe) removes it form memory. You don't have any control of this. Calling the garbage collector certainly won't help for the object is location in another thread.
Edit: you can put the following in session, it needs the serizlizable tag.
For example
<br />
[Serializable]<br />
plubic class TryToPutMeInSession<br />
{<br />
<br />
public TryToPutMeInSession ()<br />
{<br />
}<br />
<br />
}<br />
I didn't get any requirements for the signature
modified on Wednesday, December 19, 2007 11:10:04 AM
|
|
|
|
|
Putting the connection in the session is not going to be your answer, and is really not good practice. If you are able to put the connection into the session to begin with - do you have access to common methods to create and close connections?
|
|
|
|
|
Paddy Boyd wrote: do you have access to common methods to create and close connections?
of course you do...
Paddy Boyd wrote: and is really not good practice
The entire site is bullsh*t and i'm taking this oppertunity to tell my boss to rewrite it asap, but the client ís waiting for a fix like "now".
|
|
|
|
|
Sorry, as in wrapper methods like:
SqlConnection conn;
public SqlConnection GetConnection()
{
conn = new SqlConnection(connString);
conn.open();
return conn;
}
public void CloseConnection()
{
conn.close();
}
I'm guessing not.
The client might be waiting... If the code is as much of a mess as you say it is, then there might not be a quick stopgap fix for this problem. Write a scheduled script to restart the DB every so often...
|
|
|
|
|
That was about what I was planning to propose to my boss. To use the IIS recycler thing or something.
Thanks !
|
|
|
|
|
Well, I was wrong. If you use "In-process" mode of session state it does in fact keep your object in memory.
http://www.informit.com/articles/article.aspx?p=29457&seqNum=4[^]
If you don't use in-process, it stores it as xml.
But regardless, it was a poor choice to code it that way and you should fix it.
I didn't get any requirements for the signature
|
|
|
|
|
It takes a great man to admit a mistake .
Seriously though, don't worry, I really appreciated the help in any way !
(thanks for the link btw)
|
|
|
|
|
Hi
I have a Panel, which contains 'customer information', ie date of order etc. Input is aided by extenders, checkBox, date validation etc. All out of the box microsoft Ajax extenders. Works a treat. I have a close button - which when clicked, fires some javascript to remove the panel from the DOM, and then calls a webservice. The user doesn't care about the webservice, they're just pleased the panel has gone (quickly).
But....removing the panel does not remove the Script that the Ajax library injected into the page. So if they load up the Panel for the same customer, javascript errors are abound saying you can't add the same control twice - for each extender I try and add.
So...how can I, via javascript, remove the script that was added by the extender, or is there a safe way to remove the whole extender, including script, clientside. I really don't want a postback here.
Cheers
Malc
Small angry dogs
|
|
|
|
|
hello frndz.
i am using a dataset. and i want to retrivw value from that.
for that i am using
Textbox1.Text = dsAppData.Tables[0].Columns[0].ToString();
Textbox2..Text = dsAppData.Tables[0].Columns[1].ToString();
where "dsAppData" is the name of my dataset
... well through this i am getting the value.
but here the problem is.
if there are 20values neeed to be retrived from dataset.
the each time when i retrive the value i must use dataset.
so here i think it reduces the perfermance of the application as it hits
the database each time i populate the data from it.
so is ther any other way to retrive data from dataset only using once
means for the first time when we use the dataset we will keep all the requiered value
from it.
plz i need ur suggestion
|
|
|
|
|