|
A quick test seems to work fine for me. Though I'm sure you will find something wrong since it won't live up to your high standards.
public class DDLWebPart : WebPart
{
protected override void CreateChildControls()
{
base.CreateChildControls();
Button btn = new Button();
btn.Text = "Click Me!";
Controls.Add(btn);
DropDownList ddl = new DropDownList();
ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
for(int x = 0; x < 10; x++)
{
ListItem item = new ListItem("Item " + (x + 1), (x + 1).ToString());
ddl.Items.Add(item);
}
Controls.Add(ddl);
}
public void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
Label lb = new Label();
lb.Text = ((DropDownList)sender).SelectedItem.Text;
Controls.Add(lb);
}
}
only two letters away from being an asset
|
|
|
|
|
And this ddl_SelectedIndexChanged fired when the button was clicked?
did you check the SelectedIndex? Was it -1?
|
|
|
|
|
Why not just try it and see, or shall record a web video to show you since you want empirical proof, not just theory.
only two letters away from being an asset
|
|
|
|
|
I will try it tomorrow. Is the SelectedIndex = -1?
|
|
|
|
|
It is time for me to eat crow as the expression goes.
I couldn't get the code you posted to work at first in a SharePoint web part but after reviewing it I realized that what I didn't do was render the label control in the RenderWebPart override and it worked.
I appreciate your efforts in supplying this code and I apologize for doubting you when you tried to explain it to me.
I was frustrated from SharePoint behavior that was not working as I had expected, but putting the SelectIndexChange event in now allows me to access the drop down control from a button click event which is what I was trying to do all along.
I am still a little fuzzy about the inner workings but will live with working functionality until I gain a deeper understanding of the inner workings.
Do you have any book recommendations?
I would like to find some literature to get an in-depth understanding of ASP.NET Web Parts and ASP.NET. I have a lot of experience with web sites on Apache servers but not so much on ASP.NET.
I have read "Programming Microsoft ASP.NET 3.5", "The Web Part Infrastructure Uncovered", "SharePoint 2007: the Definitive Guide", "SharePoint Server 2007: Best Practices", "Programming C#", as well as taking a SharePoint and InfoPath course that was offered at work last year.
Any recommendations would be greatly appreciated.
Thanks again, and sorry for being such a pain.
|
|
|
|
|
|
Thanks for the recommendations.
I ordered them today.
|
|
|
|
|
Hi and thanks for your interest. I am trying to use an ad rotator and as soon as I use parameters in the link it shows an error. If I remove the parameters it works. How can I use parameters in the link?
Thank you.
<Advertisements><br />
<br />
<Ad><br />
<ImageUrl>http:
<br />
</ImageUrl><br />
<NavigateUrl>http:
<br />
<Impressions>50</Impressions><br />
</Ad><br />
</Advertisements>
|
|
|
|
|
You might be using this in an incorrect way. i always use XML as my Datasource and my XML loks like this
< Advertisements >
< Ad >
< imageUrl >~/images/home/Banner_1.gif< /imageUrl>
< NavigateUrl >http://www.VuyiswaMaseko.com< /NavigateUrl >
< AlternateText > Alternate Text goes here< /AlternateText >
< Impressions>50</ Impressions>
< Keyword > My Banner</ Keyword>
< /Ad >
< /Advertisements >
Now from the above you can find out what you did wrong, because that is how its Supposed to be.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
the way you use it works fine. if you add a querystring parameters it stops working.
|
|
|
|
|
Can you post on how you use it ?
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
I posted, in the question...there is a query string parameter there.
|
|
|
|
|
Hi all,
I have an ASP.NET Application that read bytes from a file (rpkey.cer) and then write bytes to another file (serverCer.cer):
String serverCertPath = @"C:\rpkey.cer";<br />
byte[] temp1 = File.ReadAllBytes(serverCertPath);<br />
string temp2 = System.Text.Encoding.Unicode.GetString(temp1);<br />
String serverCer = @"C:\TempFile\Envelope\serverCer.cer";<br />
byte[] temp3 = System.Text.Encoding.Unicode.GetBytes(temp2);<br />
File.WriteAllBytes(serverCer, temp3);
Then I copy 2 files to one folder and I realize that file A and B do not match to each other by using fc command in DOS:
fc rpkey.cer serverCer.cer
Is there something wrong in my conversion?
Best regards,
|
|
|
|
|
I'm beginner wrote: Is there something wrong in my conversion?
What problem are you getting with this ?
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
The problem is 2 files are different from each other, so my program did not run correctly when it compared them.
|
|
|
|
|
Hi,
I'm using ASP.net MVC,
In a certain controller ("Users") I have a "LoginNeeded()" method,
this one redirects you if you are not logged in:
if (CurrentUser == null)
{
HttpContext.Response.Redirect("/Users/Login/", true);
}
The problem:
If a method from the Users controller calls this method.. everything works fine.
If a method from another controller calls this method.. It doesnt find the action i'm redirecting (it tries to search in "Shared/Users/Login" and "ThisOtherController/Users/Login"
Any help?!
|
|
|
|
|
Try instead HttpContext.Response.Redirect("~/Users/Login/", true);
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
|
Hi Guys,
I am using VS2008 ASP.Net 3.5.
I have a masterpage.main where <img id="image1" src="image1.jpg" /> is located.
My problem now is, in my sub page how am I be able to change the src="image1.jpg" to image2.jpg at runtime?
For finding and changing the value of standard image control, I am using this code -
CType(Page.Master.FindControl("image1"), Image).ImageUrl = "~/images/image1.jpg"
But how will I do the same when changing the <img src=#/> value?
Any ideas?
Thanks in advance.
hifiger2004
|
|
|
|
|
|
Hi Mark,
There's an existing codes already being developed by previous developer using an img tag for all images in the master page. If it's only 1 img tag, I wouldn't hesitate to change it to standard Image control.
This is the situation now, so instead of changing all the img tag to a standard Image control I prefer to call the img and change the src value if there's a simple way of making it work.. But I am not sure if how possible, workable, I don't know.
What can you suggest, better just change them all from img tag into the standard Image control, there's no other solution?
Thanks
hifiger2004
|
|
|
|
|
Did you even look at the link I included? You're answer is there.
hifiger2004 wrote: so instead of changing all the img tag to a standard Image control I prefer to call the img
So instead of taking the time to do it right, you'll waste time on work-arounds that may not be useful in the future, in which case you'll again waste time on a work-around. But then I notice the code is VB and this is typical VB mentality.
only two letters away from being an asset
|
|
|
|
|
I have an application that is using a jquery for hover function. However.. before I conplete that function, I want to varify that the file does indeed exist on the server. Is there a jquery out there someplace to do this??
The hover event brings back a large jpg verses the thumbnail.
Thanks
gollnick
Gollnick
|
|
|
|
|
gollnick wrote: want to varify that the file does indeed exist on the server. Is there a jquery out there someplace to do this??
You have to check it before bind the image to client side. If you are using some thirdparty JQuery for doing this then it should have this features too.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
As the page is being rendered you should make the appropriate settings based on whether the file exists or not.
Something like this
if( fileExists )
link.class = "hover";
else
link.class = "no_hover";
only two letters away from being an asset
|
|
|
|