|
I am not well versed in ASP.NET so how to do this is really escaping me.
I want to display the value of one of the properties from an object conained in an arraylist using c#
This is kind of what I mean but, of course, this doesn't work
string mystr = myArrayList[0].strValue;
myArraylist[0] cantains an object with property strValue. I know I can't use the [] in the expression but how do I access that property?
The help is much appreciated.
|
|
|
|
|
This has nothing to do with ASP.NET.
Your problem is that you're using an arraylist, which is not strongly typed. In future, I suggest you define 'doesn't work', so people can help you better, but in this case, I know it 'doesn't work' because you're not casting the object. Use a List instead, never use the non generic collections.
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.
|
|
|
|
|
You're scolding me for using outdated code right?
I inherited this code with an arraylist. Maybe I should switch it over, but I did resolve my problem with the arraylist once I figured out my way around a foreach
foreach ( object myobj in myArray)
{
mystringbuilder.Append( myobj.myproperty);
}
Anyway, thanks for the reply
|
|
|
|
|
how to integrate the following pseudo-class into ASP.net
<style>
a:link {color: blue;} /* an unvisited link */
a:visited {color: purple;} /* a visited link */
a:hover {color: red;} /* a link with the mouse hovering
over it */
a:active {color: green;} /* the selected link */
</style>
because I want to realize the mousehover ona linkbutton to change the color,
but I do not know how to use the css style, for self-defined css style, we can sue sth like
<div class="style_deine_1" >
thanks!
|
|
|
|
|
Use MouseOver and MouseOut for Change the color of hover. And For Rest, only using the CSS Class.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
thanks, again, but I did not understand you.
here, I also want to know that is it possible to use these css styles in ASP.net, if so, how?
|
|
|
|
|
Ohh. I missunderstood yout question. You do it like this way,
.MyHperLink{
font-family: Verdana;
font-size: 11px;
color: #006DB1;
}
.MyHperLink:a
{
color: #006DB1;
text-decoration:none;
}
.MyHperLink:hover
{
color: #13B12D;
text-decoration:underline;
}
Do all other stuff for active etc.
Set CssClass="MyHperLink" for link button.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
thanks a lot.
I tried, it seems that css does not work for linkbutton, no idea why.
but it does work for others such as BulletedList.
|
|
|
|
|
it is strange that I can not find function to set the color for a linkbutton when mouseover,
it should be a normal function, but...
e.g. anyone can give me one hint?
e.g.
asp:LinkButton ID="LinkButton6" Font-Underline="false" ForeColor="White" BackColor="Green" Font-Size="Medium"
Font-Bold="false" Font-Names="Arial" runat="server" BorderStyle="Double"
BorderColor="Silver"> Download Statistics</asp:LinkButton>
|
|
|
|
|
use OnmouseOver and call a javascript method to change the style
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
it does not work, because I use ASP.net linkbutton, the ID can not be found by javascript function by using GetElementByID,I do not know why.
|
|
|
|
|
Seraph_summer wrote: it does not work,
It should work
Seraph_summer wrote: because I use ASP.net linkbutton, the ID can not be found by javascript function by using GetElementByID,
Seraph_summer wrote: I do not know why.
Because, your LinkButton is Server Side Control . So, for that you need to first get ClientID then need use getElementByID.
var LinkClientID="<%=mylinkbutton.ClientID%>";
var NewID=document.getElementByID(LinkClientID);
Now use NewID for all operation,
Please check syntax once
Hope this will helpful to you.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
thanks, I see, ASP.net and old technology is different, the mixed appliacitons with these
technologies make me a little confused.
one more quetion, as I just put one new question, is it possible to use CSS style to realize this function?
thank you for your help all the time!
|
|
|
|
|
Welcome. Dont forget to mark post helpful if its really help you. This lets us know which answers are good in forum !
Thank You !
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
sorry, again, after I get the id of the linkbutton (as follows), then how to change the backcolor of the button
I do not know which function can be used.
function LinkBtnMouseOver() {
var LinkClientID = "<%=LinkButton1.ClientID%>";
var NewID = document.getElementById(LinkClientID);
}
|
|
|
|
|
I try to Adding the AJAX Control Toolkit to the Toolbox as shown in this page:
Get Started with the AJAX Control Toolkit : The Official Microsoft ASP.NET
But it send me an error when I Select my AjaxControlToolkit.dll!
The Error is : There was an error loading types from assembly 'C:/Program Files/....../AjaxContolToolkit.dll'
'Could not load file or assembly 'System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, ..... or one of its dependencies. The System cannot find the file specified.'
Any Idea?
[]D @ []v[] []D @ []v[]
|
|
|
|
|
Which Framework do you have in your system ? Is it 2.0 or 3.5 ? Based on that you need to use that dll.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I Use .NET Framework 2.0! So?
[]D @ []v[] []D @ []v[]
|
|
|
|
|
Thanks man! I Choose AjaxControlToolkit Which is Compatible with my .net framework! but another problem is, i wanna use htmleditor tool, and there is no html editor! n it is just in upper version of ajaxcontroltoolkit!
Any Idea?
[]D @ []v[] []D @ []v[]
|
|
|
|
|
Hello,
For some reason I need to know which image-button causes postback. The following code does this job very well (according to coordinates). However when I click on a image button in a datalist. Somehow datalist items disappear. When I disable the codes(at pre_init) that calls the following function, the image button of the datalist works very well. Does anybody have any idea? Only you gurus would help me. Thanks in advance.
private string getPostBackControlName()
{
Control control = null;
string ctrlname = Page.Request.Params["__EVENTTARGET"];
if (ctrlname != null && ctrlname != String.Empty)
{
control = Page.FindControl(ctrlname);
}
else
{
string ctrlStr = String.Empty;
Control c = null;
foreach (string ctl in Page.Request.Form)
{
if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
{
ctrlStr = ctl.Substring(0, ctl.Length - 2);
c = Page.FindControl(ctrlStr);
}
else
{
c = Page.FindControl(ctl);
}
if (c is System.Web.UI.WebControls.Button ||
c is System.Web.UI.WebControls.ImageButton)
{
control = c;
}
}
}
if (control != null)
{
return control.ID;
}
else { return "budegil";}
}
Please clik on any "Ekle" button in the following web-page to see what I mean.
webpage[^]
|
|
|
|
|
[System.Web.Services.WebMethod]
public static DataSet GetContactName()
{ DataSet ds = new DataSet();
XmlDocument doc = new XmlDocument();
ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("App_Data/Group.xml"));
LoadData(ds); ?????
}
I need to bind this ds to a repeater control.
public void LoadData(DataSet ds)
{
DataSet ds = GetContactName();
repeaterGroup.DataSource = ds;
repeaterGroup.DataBind();
}
My question is, how to call LoadData from above webmethod. LoadData() method is not recognized from the webmethod.
------------------------------------------------------------
"The only true wisdom is in knowing you know nothing." --Socrates
|
|
|
|
|
How can a web-service method binds data? If LoadData() method is in your web page and you are trying to call it from web-service, then whatever you are doing is pointless. Do more reading on web-services and how they work before you work on them.
|
|
|
|
|
Everything has a necessity and I wanted to clearly communicate that am not a beginner.
Please ask why this is needed if you are interested to help or opt to stay out. There will be somebody else who will be willing to help. When I have posted a question on a forum, it clearly means I am looking for a solution.
This is what am trying to achieve.
Ajax control, collapsible panel extender(cpe) needs to expand a panel containing a repeater control and load data into repeater when the panel is expanded.
I found that there is no server side click event but there is an expand-collapse javascript handler.
To call server side code from AJAX, Pagemethods can be used.
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server">
</asp:ScriptManager>
[System.Web.Services.WebMethod]
public static DataSet GetContactName()
{
DataSet ds = new DataSet();
XmlDocument doc = new XmlDocument();
ds.ReadXml(System.Web.HttpContext.Current.Server.MapPath("App_Data/Group.xml"));
LoadData(ds);
}
public void LoadData(DataSet ds)
{
DataSet ds = GetContactName();
repeaterGroup.DataSource = ds;
repeaterGroup.DataBind();
}
I am not able to access LoadData from GetContactName(). Any help on this would be greatly appreciated.
------------------------------------------------------------
"The only true wisdom is in knowing you know nothing." --Socrates
|
|
|
|
|
you're not a beginner, but you want to know how to call a non static method from a static method ?
The only way to do this, is to have an instance of the class that contains the non static method. However, as your control is within a page lifecycle, you can't just create a page instance from out of nowhere, it won't create the lifecycle you need, as a page is not being requested. Therefore, it cannot be done, you need instead to create a page lifecycle, and call your method within that lifecycle. Otherwise, there's no chance you're going to see anything appear in your page.
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.
|
|
|
|
|
Hello,
In my ASP.Net application i am using AJAX. Basically i am implementing Chat Application.
At a time many chat windows will be opened and based on the AJAX time interval messages will be updated in the chat screen.
My problem is i have set default focus as the Textbox and the text box is inside AJAX Panel. for every ajax refresh in each chat window the setfocus functionality is being called and all the windows are interchanging unnecessarily. From java script i want to know weather the current page is active or not,if it is active then the focus need to be on the textbox if the current page is not active the focus should not be on the textbox. can any one help me in this regard.
Prasad.
|
|
|
|