|
hello
thanx Guffa, For ur Nice and Supportive amswer, Could u Help me out for my Web Crawling Problem.
thanx once again
byee
Dotnet
|
|
|
|
|
How to use Login Control in Visual Studio 2005
|
|
|
|
|
|
I was writing a small asp.net application with vs.net, after I finish the aspx file, I double clicked a button in aspx file, it poped out the aspx.cs file. I built the project and it functioned very well, but in solution Explorer I can not find the aspx.cs file, I know it should link to aspx file, can someone please give me some hints, thanks in advance.
|
|
|
|
|
You can see the CodeFile attribute of the Page[^] directive.
|
|
|
|
|
Thank you.
do you mean the page directive in aspx file html code, it already specify the c# file, as below
<%@ Page language="c#" Codebehind="login.aspx.cs" AutoEventWireup="false" Inherits="dsscopy.login" %>
but its just not in the Solution Explorer, which is annoying when i try to open the c# file cause its not there.
|
|
|
|
|
Are you using VS 2005 or 2003? Can you try to select the Show All Files menu item from the main menu Project and see if the source file is displayed?
|
|
|
|
|
Thank you so much for your help, problem solved.
Regrads!
|
|
|
|
|
I'm working on an asp.net project, that involves a database. I am selecting some data from the db (more than one cell from the table), and I want to cast it into an array, such as a string array or an int array (datum in a cell will be an array item).
I don't want to use a tableview or a datagrid or stuff like that. I want complete control on displaying the data on the web page.
I'll thank you very very much for replies!
|
|
|
|
|
davidstern100 wrote: I want complete control on displaying the data on the web page.
I'm not really sure how you want to display your data on the web page, and I'm doubt you'll have to build up your custom control to do what you need as the built-in ones are not so power.
|
|
|
|
|
I want to display it in a repeater. As I understand, the repeater's datasource is an arraylist.
So I'll ask the question again: How do I display data from a database in a repeater?
|
|
|
|
|
Actually, you can specify an ArrayList object or an object implementing the IEnumerable or IListSource interface in general as the datasource for the repeater control. In addition, you can simply use a data source control like SqlDataSource or ObjectDataSource to quickly bind data from a datatore to the control. For more information, you can see Binding to Data Using a Data Source Control[^]
|
|
|
|
|
Thanks for the help. I actualy soved the problem with a "Fill" command.
Now I have a new question: Once the data is bound, the ItemTemplate in the Repeater is static. I want not just to display information in it in like in a simple html file, but to add controls (a button in my case) that will use the data in the speciffic ItemTemplate. How do I do that?
|
|
|
|
|
|
ok. new question:
I am using a Repeater control in my form. I have filled it up with data from my Sql database. I have placed a button in the ItemTemplate and linked it to a function on an event of the Repeater's ItemCommand. I am able to refer to the index of the item in the Repeater (e.Item.ItemIndex).
From that function - how do I refer to an item from the data displayed in the ItemTemplate (DataBinder.Eval(blabla))?
|
|
|
|
|
+ Basically, to access the data item that is associated with each RepeaterItem, you can use the code
Repeater1.Items[indexer].DataItem and then cast it to the real type, and the DataItem property only has data when you bind data to the control and normally has the null value on postback as the Repeater control basically does not persist the bound data on postback.
+ You normally use the ItemCommand event to handle the Click event of any button placed inside the Repeater on postback. So in the ItemCommand event handler, you cannot access the data item using the (DataBinder.Eval(blabla)) or use the DataItem property (except that you rebind data to the control again). Instead, you can access the UI elements placed inside the ItemTemplate to get the displayed values. Another option is that you'll have to rebuild the data source again or store it somewhere such as the Session object after you first populate it and now you can reuse it, you then access the DataItem from the data source using the e.Item.ItemIndex or e.CommandArgument. You can see an example from the DataGrid control but that might give you an idea.
DataGrid.ItemCommand Event [^]
|
|
|
|
|
How do I access the UI elements placed inside the ItemTemplate?
|
|
|
|
|
For example, you have a label control named Label1 in the ItemTemplate, then there are two options to get reference to the Label control:
+ Use the Controls collection:
Label lbl = e.Item.Controls[0] as Label;
+ Use the FindControl method which is more flexible:
Label lbl = e.Item.FindControl("Label1") as Label;
|
|
|
|
|
Thanks a lot! You've been very helpfull!
|
|
|
|
|
Hey guys,
I have a few user controls in a ASP.Net 1.1 project. These controls are navigation controls, top and bottom menus and stuff like that and are pretty much appearing on all the pages on the site. Now I would like to implement some custom features in these user controls such as alt keys along others. So here’s what’s happening. Inside my user control I have some web controls and things like that. Lots of html elements and stuff. For instance one of the controls is representing a menu with links and stuff. If I want to expose some custom properties like this, I would have to change the ascx file right? And then I’m guessing I could just use the property as an attribute to the tag from the aspx’s html mode. Do you guys think I’m on the right track here or is there anything else I need to know??
Thanks
TINA
|
|
|
|
|
Tina P wrote: If I want to expose some custom properties like this, I would have to change the ascx file right? And then I’m guessing I could just use the property as an attribute to the tag from the aspx’s html mode. Do you guys think I’m on the right track here or is there anything else I need to know??
Normally, you can define custom properties for the web user control in its code-behind then you can declare it in the aspx web page, but iirc the VS 2003 with ASP.NET 1.1 does not support intellisense for the web user control, that means you'll have to manually type in the property name in the control declaration.
|
|
|
|
|
Thanks for your response. Yes that’s what I meant the code behind (assx.cs file). We are using a custom control also which is built as a library project with bunch of .cs files. Now for example if I want to add a new property to change or customize the tab order, how do I do that. I mean inside the .cs file I can probably come up with a new prop like this:
<br />
<br />
public string AltText<br />
{<br />
get<br />
{<br />
return strAltText;<br />
}<br />
set<br />
{<br />
strAltText = value;<br />
}<br />
}<br />
<br />
Then I could set this property by doing something like this: System.Web.UI.Control.WebControl.Image.AlternativeText = “strAltText”; This could be done because the object image does understand and expose this property called AlternativeText. However if I want something else such as Tab order set up…which is not there by default or any other third property such RotateImage…I would have to write custom code to accomplish that. And that’s where I’m getting a little confused. Not sure how to do that. Any ideas/ comments guys. By the way, RotateImage is just an example, I would want to set the TabOrder though. Is there something similar to TABIndex property that most html and some web controls also have??
|
|
|
|
|
Tina P wrote: Is there something similar to TABIndex property that most html and some web controls also have??
Tab Order, Focus, and Access Keys in ASP.NET Web Server Controls [^]
Basically, the ASP.NET custom control is designed to work at the server side and at the end the output markup of the control is the pure html, text with javascript. So when you want to do something with a custom control or you want it to accomplish a certain task, you first need to think about how to obtain that with html, javascript or you need to ask if this certain feature is doable in the html environment. And when you know that you are able to achieve with pure client side elements, you then can start thinking of implementing in the ASP.NET custom control. Take the TabIndex property for example, the html elements or the built-in custom controls basically have this attribute, but they don't have any TabOrder property and you now want your custom control to have the TabOrder. Here, you know that this task can be obtained with the TabIndex attribute of the html element, you then start implementing a custom property, say TabOrder, which in turn can be used internally in the control to set the TabIndex property of any child html/built-in control.
|
|
|
|
|
Thank you minhpc_bk for your response. It’s actually pretty helpful. I’m still not 100% sure as two how to add the ones that are not built in to the .Net framework. Such as rotating images and other weird ones. Now for instance I figured out how to do the AlternateText one and as you said above (for tabindex) this was simple coz System.Web.UI.WebControls.Image exposes AlternateText property so all I had to do is assign the text to this.AlternateText = strAltText;
This was possible because the custom control class is inheriting from for instance System.Web.UI.WebControls.Image control and image exposes that property. However something like a drop down list for instance that has no Alternative text property…is going to cause problems. So basically as you said above for such a control I’d have to see if I could accomplish that in HTML. Anyways thanks for all your help and the link to that article… also if you know anything else about the drop down list in particular, please let me know. Thanks again. ~TINA
|
|
|
|
|
Taking the AlternateText for an example, I want to demonstrate the way to implement that in a custom dropdownlist control. There are a couple of things that come to mind when I am investigating how to accomplish in pure HTML:
+ The DropDownList is a class in the ASP.NET and at the client side it is the Select html element.
+ So now that I look at the attributes, members of the Select element to see if it has the AlternateText (or Alt more exactly) attribute or any similar attribute, then I see that it has the similar one called Title . In case that nothing is found, you might widen your search to see if there is any other work-around to add this feature for the select element, for example put the select inside the div which supports the title attribute.
+ So once I know how to do in html, I now do that in ASP.NET and below is a simple custom control:
public class ExDropDownList : DropDownList
{
[DefaultValue(""), Localizable(true), Bindable(true), Category("Appearance")]
public virtual string AlternateText
{
get
{
string text1 = (string)this.ViewState["AlternateText"];
if (text1 != null)
{
return text1;
}
return string.Empty;
}
set
{
this.ViewState["AlternateText"] = value;
}
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
base.AddAttributesToRender(writer);
if (!string.IsNullOrEmpty(this.AlternateText))
{
writer.AddAttribute(HtmlTextWriterAttribute.Title, this.AlternateText);
}
}
}
I don't know off any particular article for dropdownlist, but you can do some search for that, for example this one[^]. Good luck!
|
|
|
|