|
One idea is to look at Page.Title. Usually the Title of the page is the same as the name. This gets set in the @Page directive in the aspx.
Hope that helps.
Ben
|
|
|
|
|
If you had a page called myPage.aspx and a UserControl called myControl.ascx
within the myControl.ascx.cs file you can say:
string parent_page = Parent.Title;
Or, you can do things like:
if (Parent is myPage) {
Visible = true;
} else {
Visible = false;
}
This would effectively make the control invisible on any other page than myPage.aspx, or any other pages that inherit from that page. In your myPage.aspx.cs file, you can just use the Title property directly. This is a good way to safely make UserControl objects that twiddle properties in their parent page because you can avoid the runtime error which would be caused if you tried to access properties that don't exist.
|
|
|
|
|
Hi I am trying to practice .NET and thought of doing a project on my own of Shopping cart. I want to design a webpage where users can login and buy. It should also give them a sort of report with dates when they bought the items and details of those items.
So can someone guide me with how to start the project. Please give me guidance so that I can write the code on my own and get some practice in writing code.
As per now I have designed a homepage with option of items, user login screen to login. This is just a dynamic page.
Is this right place to start. Please guide me.
|
|
|
|
|
Yeah it's a great project for a beginner. It has a good starting point with quick return on your effort, and many possible optimisations and features to play with. A good place to start though (and you had to know I would say this), is Google. As a beginner, it's best you learn this right up front. When you start a new project, Google everything you can about it. Get an idea of what the technical issues are, and what the scale of the project will be. Find out if someone has already done your project and if you can get the code from them, or buy a product to solve your issue. Put the words "sample code" and "open source" into your Google queries, and include any languages or technologies in your query as well. This will help the Google engine zero in on programming articles. After you've Googled the heck out of the issue, then if you still want to do the project, you can start writing code. Of course, you start that by not actually writing any code, but that's another issue altogether. Try this:
http://www.google.com/search?q=ASP.Net+shopping+cart+sample+code[^]
OR this:
http://www.google.com/search?q=C%23+.Net+shopping+cart[^]
(1st result is codeproject.com, also a good resource)
Google is the best programming resource ever invented. What I wonder is... to whom were 40 billion questions a day adressed before Google? Librarians?
|
|
|
|
|
Here i am sending one link contains some projects for Beginers .U can see the code also if u get any doubts.
http://dotnetspider.com/projects
if u have any doubts then mail me to pusnsuresh@yahoo.com
|
|
|
|
|
Hi, I Just Started to build this project. Everything is going on well until I came to user login page. I am getting a error msg Error 1 'ASP.login_aspx' does not contain a definition for 'Login1_Authenticate' File: Login.aspx Line 24
May be I need a code to authenticate username and password.
Can someone provide me a good code for this in C#
Database is already created as ASPNETDB.MDF
Project is been developed on .NET 2005
Thanks
|
|
|
|
|
|
I have a set of checkboxes in a Repeater control, and every time I submit the page, the Checked property is false, regardless of whether the Checkbox was actually checked or not. I really hate it when my computer disagrees with reality. The Checkbox is checked. I can see it. It's clearly got the little green check-marky-thingy in it... why doesn't my web code see it?
I looked for this issue all over the web, but the sheer number of idiots who didn't know about the "Checked" property are overloading the search results and I'm getting nothing about this particular problem (all I can find is "How do I tell if my checkbox is checked?"). I do have some "clever" code here, but the confounding thing is that this exact same set of code works fine on another page in the site. There is no difference between the two pages except for some formatting changes in the HTML. I have no idea what code is causing the problem, so here's all of it:
Here's the ASP for my Repeater control:
<asp:Repeater ID="RP_contacts" runat="server">
<HeaderTemplate>
<table style="margin: 0px 10px 0px 10px" cellpadding="2px" cellspacing="0px">
<tr>
<td style="border-bottom: solid 1px Black;"><input type="checkbox" onclick="javascript:check_all();" id="allbox" name="allbox" /></td>
<td style="border-bottom: solid 1px Black;">Contact Name</td>
<td style="border-bottom: solid 1px Black;">Email Address</td>
<td style="border-bottom: solid 1px Black;"> Phone</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox runat="server" ID="cbx" CausesValidation="true" Checked="false" />
<asp:HiddenField runat="server" ID="HF_contact_id" Value='<%# DataBinder.Eval(Container.DataItem, "contact_id" ) %>' />
</td>
<td><a href="contact_edit.aspx?id=<%# DataBinder.Eval(Container.DataItem, "contact_id" ) %>"><%# DataBinder.Eval(Container.DataItem, "name" ) %></a></td>
<td><a href="email_form.aspx?mailto=<%# DataBinder.Eval(Container.DataItem, "contact_id" ) %>"><%# DataBinder.Eval(Container.DataItem, "email" ) %></a></td>
<td><%# DataBinder.Eval(Container.DataItem, "phone" ) %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
And here's the code-behind where I'm trying to access the checkboxes:
public ArrayList get_checked_contacts() {
ArrayList result = new ArrayList();
foreach (RepeaterItem i in RP_contacts.Items) {
CheckBox c = (CheckBox)(i.FindControl("cbx"));
if (c != null && c.Checked) {
result.Add(Int32.Parse(((HiddenField)i.FindControl("HF_contact_id")).Value));
}
}
return result;
}
When this code reaches the "If" statement, the checkbox is never null, and never Checked. What is up with that? It's identifying the control correctly, but it's not retrieving the property correctly.
I check for postbacks.
I have the viewstate enabled (but I don't need it)
I have a small javascript on this page (no errors).
The code is in a UserControl.
The UserControl is in a MasterPage.
The code works fine in another page. The code is copy-pasted so it's definitely the same. The MasterPage/UserControl heirarchy is the same in both places. I have repeated the copy/paste several times just to make sure
This is also broken when I put it at the top-level of a standard ASPX page (no MasterPage or UserControls) - this says it's an actual problem with the code, and I got lucky with the page that's working correctly, which means my good page will probably fail at some point in the future. I would like to avoid that
I have tried various combinations of the properties of the Checkbox control, and the problem does not seem to be affected by EnableViewState, CausesValidation, Checked, or AutoPostBack (I can't have AutoPostback on this page, but it doesn't fix the problem anyway)
Eeeeek... I'm totally out of ideas. Maybe a fresh set of eyes is what I need... Any insight into this problem will be greatly appreciated.
-- modified at 18:19 Tuesday 6th March, 2007
|
|
|
|
|
hi,
i didn't see any problems with your code, BUT you didn't include your OnLoad code.
the reason for me asking for the code is because i think your repeater control is reinitialized every time before it reaches the 'get_checked_contacts()' function.
you should always check the IsPostback property before binding the data to any control.
in your case, i think, when the page is sent back to the server, the repeater gets a new set of data and all the checkboxes get unchecked then only the 'get_checked_contacts()' function gets called.
NOTE: the OnLoad function always gets called BEFORE CONTROL EVENT HANDLERS, at least in my case it did!
|
|
|
|
|
I did check for postbacks, mentioned that at the end. The data is already bound, and this function is called after the page is submitted. Otherwise there would be nothing in the Repeater control and nothing to pick up with Items or FindControl. I think it is a timing issue... the form post data has not been updated yet, but I'm not sure how the problem is happening. It's during the handler for the form submit that I'm doing this, and most of the time, my stuff is available as you would expect in those event handlers.
|
|
|
|
|
Does anyone know how much would cost making of medium size Web Portal in ASP.NET 2.0, C#, MSSQL 2005, CSS ... So this mean that database must be designed, admin and useradmin parts designed and 100 other stuff,
greet !
Dragoslav Zaric
MCAD, M. Sc. of Astrophysics
|
|
|
|
|
A couple of eLance websites should help you out giving a comparison chart.
|
|
|
|
|
You need to define the problem more clearly.
This is a "medium-size" project: www.codeproject.com[^]
This is a "mega-size" project: www.myspace.com[^]
The original version of Myspace was probably made in a week and cost was next to nothing. The current version of Myspace is a constant project, and costs millions to operate. Codeproject was probably fairly well-built and had taken a lot of time and money when it went online, but probably hasn't changed very much since then (they got it right the first time). My point is: "medium-sized" means nothing in this world. It's not a matter of perspective either. There is no such thing as a web site's "size". What you want to know is the development cost and other requirements, and you want this as a prediction. Even with a detailed description of the problem, an estimate like that is nearly impossible to make. Your requirements must be refined. As the problem is currently stated, I wouldn't touch it for less than $20K, but it's possible that you need something way more simple than $20K will buy - it's also possible that you need something more than that and you don't know it.
Also, if you read this:
http://en.wikipedia.org/wiki/Web_portal[^]
You will see that the term "web portal" is not clearly defined, so what you have in your head envisioned as a "web portal" may be completely different from what I might think it is. The company I currently work for is right here:
http://www.exitplanningforadvisors.com[^] - Large-size URL, but it's a medium-sized project overall. Most of the guts of it are behind security though.
|
|
|
|
|
hi all,
small question and hope to find an answer for it.
in my site i read and write news from and to database table,
in the news describtion label
how to make the width of th label fixed so that if the text line is too long it appears on many lines according to the width i choose.
i tried to set width property for the label not working,
i tried to put the label inside panal and set width property for the panal not working
div width table width all that is expanding and the text is too long as it is
plz help
Mr Emash
|
|
|
|
|
How about a Scrollable Div?
|
|
|
|
|
i tried the div but it is also get wider
|
|
|
|
|
Hi
Try using css word-wrap property
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
|
|
|
|
|
Hi,
I am trying to create my own custom providers.
I am using the Microsoft SQL providers as refference.
What i want to do is to make a set of providers which works with my own database schema.
Key points to my changes is that GUID will be replaced with an incremental Int for Primary key / Id, and i want my code to be based on the id fields instead of a username (which is currently how it works).
I have read the documentation for the Membership and Profile Providers.
In the Sql Profile provider from Microsoft the GetPropertyValues and SetPropertyValues methods are the central part, they both have an Input parameter of type SettingsContext which contains Username (username or userId according to documentation) and IsAuthenticated.
How do I make it "contain" the UserID instead of Username ?
Is there anyway to control what is in the SettingsContext collection ?
As far as I see it, it will never contain the UserID (or at least i dont know how to make it contain the userid), but probably it will contain the random generated username for an anonymous user. But please let me know how to make it use the userId as mentioned in the documentation.
Will I ever be able to make this work or am i better of creating something to "stand-alone" which isnt intended to be used in the provider model ?
If it is not recommended to create new providers, can anyone recommend an approach to creating my own "framework" for controlling users/login and such.
I was thinking of creating something very similar.
Is there some way I can register a class (maybe in the webconfig) which will run when asp.net is running, like etc. the Profile provider soo i dont have to create a new instance on every page load (and get connection string and such, but which is loaded first time it starts (asp.net/iis) and then ready for use/access all the time).
Is there any security issues i will need to think about ?
I was wondering how the build in Membership system stores if a user is logged in or not. Is the username or userid just saved in a session variable ?
I am also thinking about if i make my own framework is there any way to make it work with the existing panels or will i have to create new panels ? (for an example to determine content to show the user if the user is logged-in or not and if the user if one role or another), and what about the way you can control access to your website through the webconfig by specifying which roles have access. Is it possible to make my own "framework" work together with this ?
Hope someone can help
Best regards
Martin From
|
|
|
|
|
What is wrong with creating stored procedures and databinding or using ADO in the normal way?
|
|
|
|
|
Hi,
I am using Fusion Charts in my c# app but am having some trouble trying to reference a javascript file in my asp.net user control I had it working ok until I changed the Default.aspx page(overall navigation of the app) and now for some reason it doesn’t work anymore just wondering if anyone has any ideas this is how the file was referenced before and worked ok.
Here is the error is received…..’FusionCharts’ is undefined….
Thanks in advance
Tim
|
|
|
|
|
This is just a guess, but it seems that you have moved your page to a different directory. I am pretty sure that error is saying it can't find the FusionCharts folder.
So say you have your root folder,
off of root is fusioncharts folder,
off of root is also a Static folder in which you have the page that is getting this error.
you would need to change the path for that page to "../FusionCharts/FusionCharts.js"
Anyway just a guess.
Ben
|
|
|
|
|
I don't know if this will work for you, but what I do is add my javascript from serverside code.
For example, I'll have webApp\scripts\default.js.
Then I use the following function when I need to add the script to a page.
<br />
private void AddScriptToPage(string fileLoc)<br />
{<br />
HtmlGenericControl script = new HtmlGenericControl("script");<br />
script.Attributes.Add("type", "text/javascript");<br />
script.Attributes.Add("src", ResolveUrl(@fileLoc));<br />
this.Page.Header.Controls.Add(script);<br />
}<br />
<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
AddScriptToPage(@"/Scripts/defaults.js");<br />
<br />
} <br />
|
|
|
|
|
I have done that before as well. A very good suggestion.
Ben
|
|
|
|
|
thanks for ur help but i tried to use this function and recieved this error message
"A control cannot modify its parents' control collections"
this.Page.Header header was not an option on my page so i just used
this.Page.Controls.Add(script);
im using vs 2003 and the javascript is referenced from a user control that may be that prob
this is the project layout if its any help
Javascript
ProjectFolder/FusionCharts/FusionCharts.js
Control referencing javascript
ProjectFolder/SportsScience/View/TestFusionCharts.ascx
|
|
|
|
|
Create the function to add the javascript as public in the aspx page. Then call the function from the user control. You can pass it the name of the js file in a parameter if you choose.
|
|
|
|