 |
| ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 16th, 2010, 11:11 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 65
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
I dont know where exactly should i add the 'hov' control, in a Seperate container or in the dynamically created Form control?
when i add it in the seperate Table cell, i get a error message:
Error Message:
"The TargetControlID of '' is not valid. A control with ID 'but1' could not be found. "
i changed my codings as:
TableHeaderCell commvote = new TableHeaderCell();
Button but1 = new Button();
but1.Text = "Hover button";
commvote.Controls.Add(but1);
TableCell hovbut = new TableCell();
AjaxControlToolkit.HoverMenuExtender hov = new AjaxControlToolkit.HoverMenuExtender();
Panel pan1 = new Panel();
Label lab = new Label();
lab.Text = "Empty Panel";
pan1.Controls.Add(lab);
hov.TargetControlID = "but1";
hov.PopupControlID = "pan1";
hovbut.Controls.Add(hov); //when i add the button control here, it gives me no error message and displaying the button control, but not perfoming any hover button function. but when i add the 'hov' button here, it gives me error message as Above.
comm.Cells.Add(hovbut);//comm is the name of the TableRow.
Can you give me any example?
Last edited by Gayathri79; March 16th, 2010 at 11:18 PM..
|
|

March 17th, 2010, 12:04 AM
|
|
Registered User
|
|
Join Date: Mar 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
auto suggest
hallo sir i want to know how we can use auto suggest
|
|

March 17th, 2010, 02:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Gayathri79,
You're not really assigning an ID to the button, Naming the variable but1 doesn't give it an ID. Try something like this:
Button but1 = new Button();
but1.ID = "Button1";
but1.Text = "Hover button";
commvote.Controls.Add(but1);
If this code runs in a loop, be sure to make the ID dynamic (e.g. something like "Button" + i.ToString() where i is your loop counter).
Once each button has a unique ID, you need to assign its client ID to the hover control:
hov.TargetControlID = but1.ClientID;
The ClientID is the ID of the button in the final, client side HTML.
You need to deploy the same trick for the panel: give it a unique ID and assign that to the hover control using ClientID.
Hope this helps,
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

March 17th, 2010, 02:54 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi umeshdwivedi,
Can you please start new threads for new topics? Makes it easier to follow a thread and work with its replies.
http://www.asp.net/AJAX/AjaxControlT...oComplete.aspx
Cheers,
Imar
|
|

March 17th, 2010, 03:07 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 65
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Thank you so much. i le try that.
|
|

March 18th, 2010, 10:33 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 65
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
I tried what you told me. Button control got its uique ID. But the hover Extender control's TargetId is not finding the Button control's ClientID.
I am working with .aspx web form from Master page where i tried that, where i got a Error Message:
" The TargetControlID of '' is not valid. A control with ID 'Button0' could not be found. "
I also tried in the actual web form without using Master page. There it works. Hover control is working there.
Codings:
for (int i = 0; i <= 10; i++)// This is a sample loop. Database contains only 4 recors.
{
while (reader.Read())
{
TableRow ----
-----------
-----------
TableRow comm = new TableRow();
TableHeaderCell commvote = new TableHeaderCell();
Button but1 = new Button();
but1.ID = "Button" + i.ToString();
but1.Text = but1.ID;
Panel pan1 = new Panel();
pan1.Height = Unit.Pixel(100);
pan1.Width = Unit.Pixel(100);
pan1.BackColor = Color.Chocolate;
pan1.ID = "panel" + i.ToString();
Label lab = new Label();
lab.Text = pan1.ID;
pan1.Controls.Add(lab);
AjaxControlToolkit.HoverMenuExtender hov = new AjaxControlToolkit.HoverMenuExtender();
hov.TargetControlID = but1.ClientID;
hov.PopupControlID = pan1.ClientID;
Form.Controls.Add(hov); //If i dont use this line, i am getting only the Button, but hover is not working. otherwise i am getting the Error message. I also tried to add the 'hov' in a separate Table cell. also not working.
commvote.Controls.Add(but1);
comm.Cells.Add(commvote);
Tablevar1.Rows.Add(comm);
i++;
}
}
|
|

March 19th, 2010, 03:38 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
Looks like the Master Page is changing the client ID of the button. This is by design. Not sure why the code is not taking that into account. In what event are you doing this? Try to move your code to Page_Init. Also, take a look at the final HTML and see what the actual ID of the button is.
Also, I am not sure this is a good idea:
for (int i = 0; i <= 10; i++)// This is a sample loop. Database contains only 4 recors.
{
while (reader.Read())
{
This loops 10 times and inside that loop you loop over the database records. That means all database records get the same ID of 0....
Imar
|
|

March 21st, 2010, 03:13 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 65
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi Imar,
I was working with Page_load event. I also tried in Page_Init as you said. Looks like the same Issue.
But when i disable the hover control itself and tried to display only the Button with its CLientId. IT displayed the Button Id correctly( Each record has its own Id like Button0,button1,button2...). So looks like Master page is accepting Client Id.
But when i add the hover control, there i get a Error Message asusual:
" The TargetControlID of '' is not valid. A control with ID 'Button0' could not be found. "
Looks like a problem with Hover control Extender.
I am adding this control like:
Form.Controls.Add(hov);//hov is dynamically created hovercont********************tender.
So is there any other way to add the panel control as a popup for the Button control without using hovercont********************tender?
|
|

March 22nd, 2010, 02:55 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Can you post a stripped version of the complete source, including the master page? Then I can try it locally here. Please try to get rid of irrelevant code such as CSS etc.
Cheers,
Imar
|
|

March 23rd, 2010, 02:30 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 65
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Yes I can post it.
-Do you also want my Database file? If yes, how do you want me to post it?
-If I remove my Css file, it looks totally different with Extra large fonts. Are going to Execute the File?
-Thanks
Gayathri
|
|
 |