|
mark_me wrote: Is it a good idea to use CSS in asp.net?
Absolutely. ASP.NET, like PHP, is an engine for generating HTML, javascript and CSS ( what else could it be ? ). Therefore, it would be worthless if it had no support for a central platform of web development.
mark_me wrote: Anyways, my question is if i have a css element selectedMenu. how would i apply it to menu items on each page. menu again is css generated, used on master page...
Ultimately, if you're using css and creating a menu, this is a html/general web development issue. There's nothing in ASP.NET that could possibly hope to change how a browser reads css, or what it does with it. So, your best starting point is to look at the script being emitted, and try to work out what's missing, or in the wrong place, or whatever. Then work backwards from there, and work out why the way you're using ASP.NET is not creating the result you expect.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi, thankyou for replying but i want to re-iterate my question.
In php, you would make every page. For home page, you will use css element selectedMenu for homelink, in product page you will use selectedMenu for Product, similarly for pageN you will have PageN set to selectedMenu. That way, a user will know which page he is viewing. Inshort, every page is kinda redesigned in php.
In asp.net, you will have one template, the master... with menu in master, you can have multiple pages but how would you set css property to selectedMenu for page Product programmatically, again how would u set it to pageN programatically. Will i have to use page.Load.
Again, thanks for replying.
|
|
|
|
|
mark_me wrote: Will i have to use page.Load.
Well, plainly not. You can use the prerender event, and that's often a better idea, because it fires after events.
What you would do, is write code to change the classes of your menu items, based on what page is selected. The way I'd do this, is write a menu class that uses a session variable to know which item to show as selected, then each page sets the right value. Another reason to use prerender, so you have time to set that value first.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Hi,
I am updating an XML file (and I need to use a file because it's being used as input to a flash map (that i don't have code for)) - right now I'm implementing code that:
-checks the date on the file - if a day or more old - then update the file - using an application object to lock the file and update it.
But this application is on a server farm - so I have to have more than one copy of the file - but each will get updated using this way.
Is there a better way to do this?
Thanks in advance.
|
|
|
|
|
why dont you place it in a location common to everybody, even in database will do. In this case you are leaving out the unnecessary bugs that comes with multiple occurrence of the same file.
|
|
|
|
|
Yes I understand what you are saying -
however I'm using flash code in my application that requires as input the name of an xml file with the data the flash application needs. I want to update this data in the xml file one time per day.
So a file is required in this case - but I'm not sure of the best way to update this file only once per day.
|
|
|
|
|
You could always manage this with a scheduled application (say, a console or winforms app scheduled to run through Task Scheduler).
|
|
|
|
|
hey all.. i need a guidence to my problem im facing
i want to display data in gridview binded to a sql datasource
but the problem part is i want to bind a field of that datasource to a dropdownlist and when a item is selected in that dropdownlist then correcposnding to that data will be displayed in gridview...
i have done the binding of datasource and gridview... but not of cropdownlist...plz help buddies... i'll be very grateful ... thanks in advance
here is my code which im using
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{ con = new SqlConnection("Data Source=.;Initial Catalog=abc;Integrated Security=True");
con = new SqlConnection("Data Source=.;Initial Catalog=abc;Integrated Security=True");
cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
GridView1.DataSource = dr;
GridView1.DataBind();
Label1.Text = "Result found:" + GridView1.Rows.Count;
}
else
{
Label1.Text = "not found";
}
con.Close();
}
modified on Sunday, July 26, 2009 12:51 PM
|
|
|
|
|
Just Try this one
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet Ds=new DataSet();
con = new SqlConnection("Data Source=.;Initial Catalog=abc;Integrated Security=True");
cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
SqlDataAdapter DA = new SqlDataAdapter(cmd);
DA.Fill(ds);
if(Ds.Tables[0].Rows.Count>0)
{
GridView1.DataSource = ds;
GridView1.DataBind();
Label1.Text = "Result found:" + GridView1.Rows.Count;
}
else
{
Label1.Text = "not found";
}
con.Close();
}
Quick Suggestion :
solo_gaurav wrote: cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
Never Execute SQL Query like this from UI level. It will causes SQL Injection. Always used Parameterized query / Stored Procedure .
Thansk
|
|
|
|
|
hello abhijeet...corrected my code but tell me solution of my problem.. i.e how can i display data from datasource in tabular form when i select a bounded field of same data source in dropdownlist.. plz dear help me... thanks in advance
|
|
|
|
|
solo_gaurav wrote: ow can i display data from datasource in tabular form when i select a bounded field of same data source in dropdownlist.
Gaurav,
I am not clear about your problem. Can you please explain in details ?
|
|
|
|
|
dont worry sir i did it myself ... thanks for support and co-operation..
|
|
|
|
|
That's Cool
|
|
|
|
|
solo_gaurav wrote: cmd = new SqlCommand("select * from salescounts where ='"+DropDownList1.Text+"'", con);
As the other poster had mentioned, this opens you up for a potential SQL Injection attack. I recommend reading SQL Injection Attacks and Some Tips on How to Prevent Them[^] by Colin Mackay on this site.
If you could shed some light on what are actual data values of DropDownList1.Text would be helpful. Your trouble might be what is being generated as the SQL string and causing it not to bind the data.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
my system did not contain machine.config is not there in the bellow path. How to create machine.config in my system ?.is it mandatory to run asp.net
project or not.
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322(gacutil.exe and regsvcs.exe) are there in that location.
|
|
|
|
|
Ramesh Reddy11111 wrote: my system did not contain machine.config is not there in the bellow path
It is never supposed to be there in the path you mentioned but should be present at the location below:
C:\Windows\Microsoft.NET\Framework\v1.1.4322\CONFIG
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I have a wizard control in my form. In one of the steps there is a file upload control. If the user uploads a file using the browse button and then he clicks on Next button instead of Upload button, the textbox gets cleared.
Is there anyway to retain the string entered in fileupload control textbox so that the user need not enter again? Please help.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
only way is to place the upload file code in the next button as well, check if file is there and if so then upload it while the user is clicking on Next button
|
|
|
|
|
Thanks for the reply. But again, i have to either repeat the code or write the code in a function and call it, which I think is redundancy of code. So what I am thinking is, I can save the file name in the viewstate while uploading. So if viewstate is null, then I can disable the nextbutton else enable it.
So while loading the tab itself, it is disabled since there is no filename in viewstate. So the user has to upload the file.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
I am not a very fond of using ViewState, as it is transferred through the request/response body all the time, hence increasing the size of the data transferred.
Anyways, nice to hear that you got the solution.
|
|
|
|
|
Hi,
Although I have writing C# applications for several years, I only recently launched my first ASP.Net website. The site is run by an internal database in the App_Date folder. The Login page defines a group of Session variables that are retrieved, as needed, from concurrent pages. The Login page works perfectly and loads the Session information to the next page> That page, for security purposes, requires that an additional Password (called Signature) is submitted before it is allowed to advance. The problem is: the next page fails to load because the Session variables needed to load the next page have been nulled, as reported by the following error page:
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 456:
Line 457: //Get Session Variables
Line 458: FName = Session["FName"].ToString(); /////This line is highlighted. Changing the order of the variables always reproduces the error on the same line number of the code (458)./////
Line 459: userName = Session["Name"].ToString();
Line 460: site = Session["Site"].ToString();
Source File: \\frigga\home\users\web\b157\\QueryLogger\Alerts.aspx.cs Line: 458
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Alerts.Page_Load(Object sender, EventArgs e) in \\frigga\home\users\web\b157\hy.softdynamics\QueryLogger\Alerts.aspx.cs:458
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
Now, I am sure that the first page pass is working correctly because some of the data displayed on that page is the result of Session value queries to the database. That leaves the following question: What would cause the Session values to be nulled when passing from the second to the third page? .... and could this the result of improper >Net framework on the hosting server? Or perhaps anything else? Any help would be greatly appreciated.
Pat
|
|
|
|
|
Pat,
Where did you stored data in the Session? Your application is running from VS or IIS ? What is the session mode ?
Always check session null before read the value from it.
if(Session["FName"] !=null)
FName = Session["FName"].ToString();
|
|
|
|
|
Yes, thank you for pointing that out Abhijit. I will make that change immediately (I was in too much of a hurry.. ). But the problem is still there. The server is hosted by a hosting service (Hypermart), so I am not sure about the server, but I think it is IIS. I'll try to find out and let you know....Pat
|
|
|
|
|
I think you are trying to retrieve the Session variable after clearing out it.
Check like this
if(Session["Variable"] == null)
{
}
else
{
}
|
|
|
|