|
neodeaths wrote: SqlConnection conn = new SqlConnection("HASDBConnectionString1 ");
This is wrong. I am afraid whether you know .NET or not.
Use like this,
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HASDBConnectionString1"]);
|
|
|
|
|
!!
it works now thx
SqlConnection conn = new SqlConnection((ConfigurationManager.ConnectionStrings["HASDBConnectionString1"]).ToString());
and by the way the first argument need to be change to a string first be4 used
but thx for everything really appreiciated it
at the mean time i am gonna go read and test the executescaler method more thx alot
|
|
|
|
|
It is something in the web.config. If it doesn't exist then your code won't work. You really should abstract that kind of all out into a configuration class that can handle events such as missing configuration elements.
|
|
|
|
|
hi,
If you are using Asp.Net 2.0 your code
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"));
should be
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString());
next I dont know abt the code you are using in web.config if it can work that way but here is what I use
<configuration>
<appSettings>
<add key="connectionString" value="initial catalog=----;data source=---;user id=---;password=---;">
</add>
</appSettings>
</configuration>
try by changing the first code only see if that works
Regards,
Maggi
|
|
|
|
|
Hi there!
I have deployed my site on an IIS server.
And its working fine.
But I don't know how to access it from other machines..
I have tried accessing by
http://192.168.1.28
where the number is the IP of the IIS server.
Thanks for your help..
You don't have to be AFRAID!
|
|
|
|
|
Try like this
http://192.168.1.28/yourvirtualdirectory/home.aspx
OR
http://yoursysname/yourvirtualdirectory/home.aspx
|
|
|
|
|
Which is the Operating System of your Webserver (IIS Server)?
If it is Windows XP (SP2 Installed), the personal firewall blocks the other machine to connect the server through the port 80 (TCP/IP default port). You have set exception in the firewall to the 80 port.
|
|
|
|
|
Hello, I am trying to enable/disable a textbox prior to the page rendering based on its value. To be able to access the textbox value I had to implement this in Page_LoadComplete event of the page. After the enable/disable logic in Page_LoadComplete I obtain a boolean value that I save to ViewState and access it from Page.IsPostBack( ) method of Page_Load. I tried using ViewState to save the value as string and retrieve it in Page.IsPostBack( ) method but I am getting a NullReferenceException meaning the value of the ViewState variable is null. Why is the state not saving in ViewState variable? Here is my Page_LoadComplete method:
public void Page_LoadComplete(object sender, System.EventArgs e)
{
//Here I obtain value of textbox and based on it's value enable or disable the textbox
//Obtain a boolean value that I need to pass to Page.IsPostBack( ) method of Page_Load
ViewState["istempVar"] = aboolValue;
}
I am trying to access this ViewState variable in:
public void Page_Load(object sender, System.EventArgs e)
{
...
if (Page.IsPostBack )
{
// obtain ViewState["istempVar"]
}
Any help is appreciated.
Thanks.
|
|
|
|
|
tjkota wrote: I save to ViewState and access it from Page.IsPostBack( )
The LoadComplete event occurs after all postback data and view-state data is loaded into the page and all controls on the page. In order for view state to work for controls that are added dynamically, they must be added in or before the pre-render stage of the page life cycle.
|
|
|
|
|
Hi I am getting an error in my website that i dont understand.
The message is here on line 53 in web.config - I use similar assemblies previous to this in the file such as System.Web.Security.SqlMembershipProvider
and the type below can be called from .cs pages. Any ideas?
Thanks
Dan
Server Error in '/TraffordCentre' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Source Error:
Line 51: connectionStringName="LocalSqlServer"
Line 52: applicationName="/"
Line 53: type="System.Web.Security.SqlRoleProvider,
Line 54: System.Web.Version=2.0.0.0, Culture=neutral,
|
|
|
|
|
Hi,
i want to notify user (and so update user session) when another user was update data(data in her session).
(like create a listner turning in application server how fire event when each user update her session, and so each user catch this event and modifi data !!!!)
thks for help
Developper
|
|
|
|
|
Good luck with that.
You probably can't create a viable "listener" in a web environment. Implement some form of record locking to prevent multiple people from updating the same record and update your display periodically (every 30 seconds or so). That's probably the best you can do.
|
|
|
|
|
|
Is it possible to edit the element in a page built using code behind?
Thanks,
A
|
|
|
|
|
Yes. There is a Page variable that has a Header object.
Here is a sample from MS help:
Visual Basic
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim bodyStyle As New Style()
bodyStyle.ForeColor = System.Drawing.Color.Blue
bodyStyle.BackColor = System.Drawing.Color.LightGray
Page.Header.StyleSheet.CreateStyleRule(bodyStyle, Nothing, "BODY")
Page.Header.Title = "HtmlHead Example"
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1"
runat="server">
<title>To be replaced.</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>HtmlHead Class Example </h3>
<asp:label id="Label1"
text = "View the HTML source code of this page to see the title
and body style added to the header element."
runat="server">
</asp:label>
</form>
</body>
</html>
C#
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
Style bodyStyle = new Style();
bodyStyle.ForeColor = System.Drawing.Color.Blue;
bodyStyle.BackColor = System.Drawing.Color.LightGray;
Page.Header.StyleSheet.CreateStyleRule(bodyStyle, null, "BODY");
Page.Header.Title = "HtmlHead Example";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1"
runat="server">
<title>To be replaced.</title>
</head>
<body>
<form runat="server">
<h3>HtmlHead Class Example</h3>
<asp:label id="Label1"
text = "View the HTML source code of this page to see the title
and body style added to the header element."
runat="server">
</asp:label>
</form>
</body>
</html>
Hope that helps.
Ben
|
|
|
|
|
Thanks Ben, just what I needed.
Alice
|
|
|
|
|
I am new to ASP.Net and learning on my own.
Is there any code or tutorial anywhere on the net on ASP.Net that encompasses every knowledge to build a simple small website; from graphics design to deployment.
Thank You!
X
|
|
|
|
|
Hi there!
Go to the official site of ASP.NET.
There you can find some really good videos for beginners.
There are some 13 videos for beginners.......
And if you finish them. Then you can build a really heavy application.
http://www.asp.net/
You don't have to be AFRAID!
|
|
|
|
|
I am a bit late to VS 2005. Today I am looking at ways to rebuild one of our websites in .NET 2.0. Rather than convert I am recreating pages as I go. This isn't an issue because they need to be reworked anyway.
I opted against using the VS 2005 Web Applications Project tools to emulate 2003 in 2005 and don't want to consider that option. This site is going to be redone as a new site would.
That being said...
Our current site is made of of pages derived from a BasePage. They host user controls derived from BaseControl. Using these 2 base classes we have every page automatically check user authentication, redirection, and other housekeeping. This is done entirely on BasePage and is available to BaseControls.
If that is unclear, when a user accesses a page the BasePage checks several sources for user authentication (Session,Cookies,Database). If not correct, the user is redirected to a SignIn or AccessDenied page. If correct, the user's state is loaded for the page. From there all components on the page can query the state and populate their contents.
How would I make this work for a MasterPage setup?
The master page (as I see it) will host my UserControls directly (header, footer, side-menu). These user controls need access to the user state. The hosted content pages will also need to access the same state. I don't want each separate component hitting the database loading bits and pieces.
Basically:
Request page<br />
Page is assembled<br />
Check for security<br />
If needed, redirect<br />
Otherwise, load state for page<br />
Header populates with state info<br />
Side-menu populates based off state info<br />
Content page populates based off state info<br />
Send page to client
Something tells me that I am not quite "getting it". Am I supposed to load up the Session with huge state objects? I wouldn't think so. Too many simultaneous users for that. Can I just bulk up the MasterPage to do everything? I am lost.
|
|
|
|
|
First of all, why not use the "VS 2005 Web Applications Project template"? I use it all the time. I like compiling the apps before deployment.
Now about your design. I see no reason to put a user control in the Master Page. Why would you do that? A User Control is something designed to be used on multiple pages, the master page is on every page. So why would you have user controls in a master page?
Checking authentication in the master page is fine, then redirect to another page not in the Mater Page. Note you can have more then one master page. I think what you are asking is how to access controls in the master page from your pages and vice versa.
Let's say you wanted to handle an event from a control in the Master page on your base page, you would do the following.
<br />
ddl = (DropDownList)this.Master.FindControl("ddlMain");<br />
ddl.SelectedIndexChanged += new EventHandler(ddlMain_SelectedIndexChanged);<br />
<br />
<br />
protected void ddlMain_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
}<br />
<br />
<br />
Now if you want to access anything in your master page as long as it is not "private"
<br />
YourApp.Site objMasterPage = YourApp.Site;<br />
objMasterPage.CallPublicMethod();<br />
|
|
|
|
|
Thanks for the reply. It, with the information I've gathered today sets me on the right course.
You are absolutely right about the UserControl on the MasterPage. I got caught in old thinking vs. new thinking on that one. In .NET 1.1 I created an ASCX for the header, footer and menu becaues they actually were being created on every page dynamically. I just carried that idea forward. Thanks for setting me right.
I won't be doing any events across boundaries like your example but I may in the future and now I'll know. Thanks again.
And the YourApp.Site.Method was another piece that I was absolutely needing. I was going to be requiring all content pages to do something like ((MyMasterPage)this.Master).CallMethodHere.
Many, many thanks.
|
|
|
|
|
Hi all,
I am having a webpage in which I am printing a code behind textbox text value on to the paper by using vbscript function.
I have binded this function to a button. Everything is going clear upto this. But when I tried to I changed the text box text and click the print button, its printing before value only, but not the latest value.
I have tried in many ways to achieve this, but still it was taking previous value of the text box but not the latest one.
Please give me some idea to overcome this problem. Thank you.
Regards,
Aleem
S/W Engineer
Akebono Soft Technologies
aleem_abdul@akebonosoft.com.
|
|
|
|
|
Dear All,
I am making web application using Asp.net C#(Visual Studio2005). And Sql server 2005 as a back End
I generated local mode report but as there was no printing option available . I assign printing feature to button click by exporting the data to EMF format and print
Now when I run it through IDE VS2005 then it does not show any error.
But when I run in through IIS in intranet it showing me this error
The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process
Where I am going wrong please guide me.
Code used are
Button click code
protected void Btnprint_Click(object sender, EventArgs e)
{
LocalReport report = new LocalReport();
vw_tranTableAdapter da = new vw_tranTableAdapter();
report.ReportPath = @"D:\Inventracksys\inventorytracking\Vendorwisereport.rdlc";
report.DataSources.Add(new ReportDataSource("tran_vw_tran", da.GetDataByvendor(RadioButtonList1.SelectedValue, DropDownListvendor.SelectedValue)));
export(report);
m_currentpageindex = 0;
Print();
}
Creating stream as
private Stream CreateStream(string name, string filenameextension, Encoding encoding, string mimetype, bool willseek)
{
Stream stream = new FileStream(@"D:\Inventracksys\Inventorytracking " + name + "." + filenameextension, FileMode.Create );
//Stream stream = new FileStream(name + "." + filenameextension, FileMode.Create);
m_streams.Add(stream);
return stream;
}
Exporting to EMF
private void export(LocalReport report)
{
string deviceInfo = "<deviceinfo>" + " <outputformat>EMF" + " <pagewidth>9in" + " <pageheight>12in" + " <margintop>0.25in" + " <marginleft>0.25in" + " <marginright>0.25in" + " <marginbottom>0.25in" + ""; Warning[] warnings; m_streams = new List<stream>(); report.Render("Image", deviceInfo, CreateStream, out warnings);
foreach (Stream stream in m_streams) stream.Position = 0;
}
Printhandler event
private void PrintPage(object sender, PrintPageEventArgs ev)
{
Metafile pageImage = new
Metafile(m_streams[m_currentpageindex ]);
ev.Graphics.DrawImage(pageImage , ev.PageBounds);
m_currentpageindex++;
ev.HasMorePages = (m_currentpageindex < m_streams.Count); }
printing option
private void Print()
{
const string printerName =
"Microsoft Office Document Image Writer";
if (m_streams == null || m_streams.Count == 0)
return;
PrintDocument printDoc = new PrintDocument();
printDoc.DefaultPageSettings.Landscape = true;
printDoc.PrinterSettings.PrinterName = printerName;
// lblerrmsg.Text = printDoc.PrinterSettings.PrinterName;
if (!printDoc.PrinterSettings.IsValid)
{
string msg = String.Format(
"Can't find printer \"{0}\".", printerName);
//MessageBox.Show(msg, "Print Error");
lblerrmsg.Text = "Print Error";
return;
}
printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
printDoc.Print();
}
public void Dispose()
{
if (m_streams != null)
{
foreach (Stream stream in m_streams)
stream.Close();
m_streams = null;
}
}
Now when I run it through IDE VS2005 then it does not show any error.
But when I run in through IIS in intranet it showing me this error
The process cannot access the file 'D:\Inventracksys\Inventorytracking Vendorwisereport_1.emf' because it is being used by another process
Where I am going wrong please guide me.
Thanks
regards
imran khan
|
|
|
|
|
hi
i wanted to perform a search for records based on the date range specified by the user..
the input method is by way of calender extender(Ajax toolkit) which is in mm/dd/yyyy
before going to the web from i just queried the table using the query builder and it constructed a query
SELECT patient.*
FROM patient
WHERE (Dt BETWEEN CONVERT(DATETIME, '2006-08-09 00:00:00', 102) AND CONVERT(DATETIME, '2006-09-09 00:00:00', 102))
now how do i use the same query to the webform... also how will i display the results in a gridview control..
thx
Kunal
|
|
|
|
|
how is it possible to set the access rights and permissions for roles and members dynamically at runtime in ASP.Net??
|
|
|
|