|
Remove the Namespace from both .cs and aspx.cs .... It ll work
|
|
|
|
|
actually not a good idia to remove them. but even in that case it fails
Чесноков
|
|
|
|
|
Try this.
First Create a class in App_Code,like the below
using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public class Class1
{
public Class1()
{
}
public string test()
{
return "Test";
}
}
and create the object for that class in default.aspx.cs, like
Class1 cls = new Class1();
and call the function "Test" in default.aspx.cs
string str = cls.test();
Regards,
Karthik K...
|
|
|
|
|
Without any contructors when you type in SomeClass inside default.aspx.cs it is absent in the list of objects available.
Adding constructor does not help. Still the simple declaration of object is forbidden. It is not visible from .aspx.cs
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: but it is in the same namespace and should be visible as in C# projects.
Yes,it will work.
Check the namespace. Is it same? May be bymistake you have used different namespaces .Just check that..
himanshu
|
|
|
|
|
Just Create a new ASP.Net project you ll not get any namespace.
ASP.Net .cs files Namespace is not required.
|
|
|
|
|
freshers wrote: Just Create a new ASP.Net project you ll not get any namespace.
Yup that i know..
But still you can manually add namespace to you page
himanshu
|
|
|
|
|
May i know the Need of It
|
|
|
|
|
|
the namespaces are all the same.
even if I change SomeClass.cs embedded in another namespace, that one also is not visible, even in intelligent help. I can not access SomeClass.cs object in any case??
Чесноков
|
|
|
|
|
it needed to change 'BuildAction' property of SomeClass.cs to 'Compile'
Чесноков
|
|
|
|
|
I am using membership provider DB created using ASP.NET configuration. working fine on my machine.
I after deploying I get the below error when I click login button
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I get Error 26 when I try to run a SqlCommand object referencing the same connection string, but the membership provider works properly.
Is that I need to install sql server on the server or .NET frame work will takcare of it,
I am new to ASP.NET programming/ deploying please help me
|
|
|
|
|
The membership provider DB will be stored in SQL Server. Therefore you need to have SQL Server in the deployed server. Also change your membership provdier connection string details accordingly in the web.config.
|
|
|
|
|
Hi all,
Am trying to send an email from my asp.net page.
Am using 5 textboxes and a button.
Following is my code ,
After clicking the submit button it is displaying that mail sent successfully.
How to ensure that mail has been reached.In my gmai maibox no msg was there.
Can anybody tell me.??
Submit Button click event
Dim tc, cc, bcc, subject, body As String
tc = _txtTo.Text
cc = _txtFrom.Text
bcc = _txtBCC.Text
subject = _txtSubject.Text
body = _txtMessage.Text
Dim status As Integer = sendMail(tc, cc, bcc, subject, body)
If (status = 1) Then
Response.Write("your mail has been sent successfully")
Else
Response.Write("sorry! your mail could not be sent�")
End If
My sendMail fuction
Private Function sendMail(ByVal tc As String, ByVal cc As String, ByVal ccc As String, ByVal subject As String, ByVal body As String) As Integer
Try
SmtpMail.SmtpServer = "localhost"
Dim msg As MailMessage = New MailMessage
msg.From = "mymail@gmail.com"
msg.Cc = cc
msg.Bcc = ccc
msg.Subject = subject
msg.Body = body
SmtpMail.Send(msg)
Return 1
Catch ex As Exception
Return 0
End Try
End Function
kissy
|
|
|
|
|
Hi,
calling SmtpMail.Send just passes the message to your smtp-server (localhost in your case). This doesn't say anything about if the mail was "physically" send to gmail. You have to check if your smtp-server has trouble sending the mail to gmail. Have a look in the queues of your smtp-server (can be found under inetpub). Then check for errors in the event log. It could also be that gmail doesn't allow that messages are sent to them by your smtp-server (for security reasons).
Let me know if you need some further help.
Regards
Sebastian
|
|
|
|
|
Thanks for ur prompt reply.
Ya under inetpur,my mail messages were with msg icon.
then form here what i have to do,so that i can send mail to any mail account of the user?
Please dont feel trouble let me know how can i send msgs from my asp.net page.
please....
kissy
|
|
|
|
|
Hi All
I have a web application in asp.net 1.1 and sql server 2000, it was running alright previously, but for some weeks users are reporting that they are facing error.
In the application whenever any error comes , user is being redirected to an error page and the actual error message comes to our(the programmers) email.
The error message is very long but I'll mention the important part:-
In the email :-
System.NullReferenceException: Object reference not set to an instance of an object. at CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
The code for function CBSolutions.ETH.Web.newlook.VSPage.LoadPageStateFromPersistenceMedium() is :-
protected override object LoadPageStateFromPersistenceMedium()
{
if (ConfigurationSettings.AppSettings["ServerSideViewState"].ToUpper() == "TRUE")
{
string VSKey;
VSKey = Request.Form["__VIEWSTATE_KEY"];
if (!(VSKey.StartsWith("VIEWSTATE_")))
{
throw new Exception("Invalid VIEWSTATE Key: " + VSKey);
}
if (ConfigurationSettings.AppSettings["ViewStateStore"].ToUpper() == "CACHE")
{
return Cache[VSKey];
}
else
{
DataTable VsDataTable;
DataRow DbRow;
VsDataTable = ((DataTable) Session["__VSDataTable"]);
DbRow = VsDataTable.Rows.Find(VSKey);
// if (DbRow!=null)
// {
// throw new Exception("VIEWStateKey not Found. Consider increasing the ViewStateTableSize parameter on Web.Config file.");
// }
return DbRow["VsData"];
}
}
else
{
return base.LoadPageStateFromPersistenceMedium();
}
}
Also in the Event Viewer application log, the following warning appears:-
Event code: 3005
Event message: An unhandled exception has occurred.
.
.
.
.
.
Thread information:
Thread ID: 6
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.HttpServerUtility.MapPath(String path)
at ETH.Global.Session_End(Object sender, EventArgs e)
Here ETH.Global.Session_End(Object sender, EventArgs e) is written in Global.asax which is as follows:-
protected void Session_End(Object sender, EventArgs e)
{
//clean up temporary files
string[] files = System.IO.Directory.GetFiles(Server.MapPath("Files/"),"WF-" + Session.SessionID + "*.*");
for(int i=0;i<files.Length;i++)
System.IO.File.Delete(files[i]);
Response.Redirect("default.aspx");
}
Also, the server has Windows Server 2003.Also some weeks back server was updated to Sql Server SP4.
Any help is appreciated.
Thanks
Raj
|
|
|
|
|
As the exception says,you must be eccesing some object that is not instantiated properly.So debug it and find which object is not getting created properly.
|
|
|
|
|
Good Question but when you post in CP use the < pre > tags to format your code, i would like to help , but i loose interest because your code is not formated well
int i=0;
try to format it
and we will answer
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
iam having two user controls u1 and u2 .i have one public method in u1 .now i want to call this method in u2.how can i handle this one .
|
|
|
|
|
Remember i order to do that in U2 you must register the U1 and after that you can access your u1 method in U2 like this
u1.Mymethod();
Hope this Helps
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
this is not working ...is any other way to do that one
|
|
|
|
|
What is it that is not working ? Tell me what you did because that is how its done.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
hi Maseko,
actually in my application there are neary 25 webpages which are using two user controls tat are banner and navgation user control..but in each page the ids of these two controls are different and they have used according to the pagenames..now there is a situation that the method of one user control u1 is required to used in the u2 when a button in the u2 is clicked..
|
|
|
|
|
Good Morning lakshmichawala
I will show you an Example of how you do it. i will create a Small Example.
First i will create a usercontrol and name i U1 like and it will have a method that will display a string like this
cs will look like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class U1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public String Message()
{
return "Message from U1 User control";
}
}
and the html will be like this
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="U1.ascx.cs" Inherits="U1" %>
<asp:Label ID="lblU1" runat="server" Text="Usercontrol 1"></asp:Label>
and second thing is to create a Second user control and name it U2
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="U2.ascx.cs" Inherits="U2" %>
<%@ Register src="U1.ascx" tagname="U1" tagprefix="uc1" %>
<asp:Label ID="lblU2" runat="server" Text="User Control 2"></asp:Label>
<p>
</p>
<p>
</p>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
as you can see i have registered the U1 and in my U2 i can use the Function that i have made public like this in the button click
protected void Button1_Click(object sender, EventArgs e)
{
U1 obj = new U1();
String Message;
Message = obj.Message();
Response.Write(Message);
}
and a hardcoded message will come from the U1.
Hope this helps
Thanks
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|