|
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!
|
|
|
|
|
Hello minhpc_bk, I just wanted to say thanks....this is awesome. You should be an instructor or something Really though, it does make sense the way u explained this to me. However since I'm just a beginer (its been few months since I've been using .Net) it will take some time.
For now I have a question regarding the AddAttributesToRender(writer) method.
I am assuming that this is the same as the simple render method...you just liked to call it AddAttributesToRender?????
Secondly, once I have this AlternativeText attribute defined, then I can simply use it when I declare for instance a drop down list like this:
<select AlternativeText="myList" id="BackColor" runat="server"
Now this is simply setting the property that you have defined in the code above...I guess I'm trying to figure out the relationship between just doing this and calling the mehtod AddAttributesToRender()?
Thanks again for your help!
TINA
|
|
|
|
|
Basically, there are a couple of options that you can use to set the Title attribute using the AlternateText property:
+ You can simple put your code in the set part of the AlternateText property and add the Title to the Attributes collection:
public virtual string AlternateText
{
get
{
...
}
set
{
this.ViewState["AlternateText"] = value;
this.Attributes["title"] = value.
}
}
+ You can set the title attribute when the control is rendered. Normally, there are some overridable methods get called when the control is in the rendering phase (you should read more about control life cycle in MSDN), and your job is to choose the right one to override. For example, we can override the AddAttributesToRender method to add HTML attributes and styles that need to be rendered to the writer object, or we override the RenderXXX methods when we want to add the contents or something similar to the writer. You can check out which methods are overridable and their meaning by looking at the APIs of the base class(DropDownList for instance).
+ Once you define a public custom property, AlternateText, you can define your custom control in the web page like this:
<uc1:ExDropDownList AlternativeText="myList" id="BackColor" runat="server" ...
When the ASP.NET parser parses the ASP.NET markup, it will generate code to set the AlternateText property of the custom dropdownlist based on the value specified in the control declaration, and then when the control is rendered, the AddAttributesToRender method gets called and the Title attribute is sent out to the writer object along with the control html markup.
For more information on developing custom control, you can see MSDN[^]
|
|
|
|
|
Thanks a lot, this is great, I absolutely love the way you explain things...appreciate it once again!!! I'm going to read more about this tomorrow morning.Thanks again
~ Tina
|
|
|
|
|
hey guys...
My question involves deploying my website to the production server. I created a small batch file that copies all of the nessisary files over to the other server and ithat is working nicely. what isn't working nicely is that i lose my session state every time i run the update script. the session state id is remaining the same but all other data is gone. any idears?
andrew
|
|
|
|
|
IMHO, you might want to check if your application is recycled when you run your script, anyway here are some tips[^] that may help you diagnose your issue.
|
|
|
|
|
Hello,
Looking for a vb.net 2003 function to get the path of the "Documents and Settings" system directory for a windows app'.
I think I already seen something like:
Declare Function getDirectoryXX Lib "kernel32" Alias "getDirectoryXXA" (ByVal X As String, ByVal KeyXX As String, ByVal sString As String, ByVal sFileName As String) As String
Thanks in advance!
Just Relax And Keep It Simple.
|
|
|
|
|
In addition to p\invoke, you can use the method Environment.GetFolderPath to look for what you might want. However, it seems the question should belong to the VB.Net forum instead of the ASP.NET.
|
|
|
|
|
Hi, I want to store a returned value to a hiddenField1 asp.net variable in javascript. I tried declaring the hidden field gave name but my when i tried to display the value of hiddenfield1 variable in my asp.net onclick button event it's return empty. Is it even possible to initialize asp.net variable in javascript. can somebody tell me how to do.
Thanks
<asp:hiddenfield id="HiddenField1" runat="server">
function File1_onclick() {
var HiddenField1;
alert(document.getElementById("File1").value);
HiddenField1=document.getElementById("File1").value;
}
|
|
|
|
|
I don't understand what you are trying to do. So, I'll give an exemple:
Declare the hidden like that:
Protected WithEvents hiddenWo As System.Web.UI.HtmlControls.HtmlInputHidden
you this html in client side:
<input id="hiddenWo" type="hidden" name="hiddenWo" runat="server">
In server side you could just use it like that:
<br />
If hiddenWo.Value <> "" Then<br />
'do something<br />
else<br />
'do something<br />
end if<br />
In client side:
<br />
document.getElementById("hiddenWo").value+=2 + "|";<br />
Hope it helps!!
Just Relax And Keep It Simple.
|
|
|
|
|
Try to use OnChange event handler instead of OnClick
|
|
|
|
|
I am using ASP.net c# to display a report such as this:
There will be one main row and several children rows. And again one main row and children rows. I want this to be displayed in this manner with the option to expand and collapse the children row within the main row.
How do I do this? Can it be done using the DataGrid Web Control?
|
|
|
|
|
|
Can any one tell me how to generate Dynamic columns in reporting services....
I am using Matrix report in reporing services.
Regards,
Kalyan
Kalyan
|
|
|
|
|
Hi Developers
Can you please guide me how to add OptGroup in ASP.net DropDownlist. List elements will be populated from database. Thanks
Lets work it Out.........!
|
|
|
|
|
The built-in control does not support this attribute, that means you'll need a custom control instead. Here's an example from CP[^].
|
|
|
|
|
Thanks for your help its realy nice control But problem is that im using ASP.net 1.1.
So what to do with 1.1???
Lets work it Out.........!
|
|
|
|
|
I guess that you can easily convert the control to the ASP.NET 1.1, IMO the main thing here is that you have to override the RenderXXX methods to inject the tag optgroup to the control output markup.
|
|
|
|
|
Hi,
Can anyone tell me wat is the best way for ONLINE payments using credit cards..(it has to be world wide)
I know there is PayPal ..can any one tell me the steps in detail...
I came to know that Paypal service is not in India..is that True???
can u plz suggest me some other alternative which accepts both Dollar and money transfer(i.e)both US and India Credit Cards...
Awaiting for ur speedy responses
Thanx in advance!!
Regards
Bino Varghese.V
|
|
|
|