Link to home
Start Free TrialLog in
Avatar of steve_mick972
steve_mick972

asked on

User Controls

Hi,
  I have two user controls on a webform. one user control has a link button and this is at the top of the page and whenever I click on that link it should display the secod user control and that will be at the bottom of the page.... so far, I could do it.. but at the same time whenever I clicked on the first usercontrol's link button I want that part of the page shown to the user where the second user control is placed (bottom of the page)... I've tried many ways but im not successful. I've used FindControl of the page and passed the id of the control but it is not working...
 By the way to display the secod user control im declaring the linkbutton in the fist user control as public and handling the click event in the webform and writing appropirate code to display the second user control when the click event is occured...
Any help in this regard will be greatly appreciated...

Thank You...
Avatar of _TAD_
_TAD_



Well.... the easiest way would be to put a name tag on the HTML page like:
<a name="Control1"></a>

Then in your click event, just Response.Redirect("myAsp.aspx#Control1")


At least this works with standard HTML and ASP pages.  I would think it would work with .net (although I must admit I've never tried it)

Avatar of steve_mick972

ASKER

TAD,

Actually this would work but in my case, Im also dynamically loading the user control on to the page when this clicking event occurs, but when I am using Response.Redirect by the time it loads the user control and display the user control it is redirected to original page without  usercontrol, but ofcourse it is showing the portion of the page which I want to see...
So, If I could make the user control loaded onto the page and also go to that part of the page where I am placing the user control would be great...

Thank you for the help anyway..
ASKER CERTIFIED SOLUTION
Avatar of KarunSK
KarunSK
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Karun,
       That was simply great... U know I was doing the same thing what u told me to do except one stupid mistake which took me this long to figure it out (until i saw ur code)..., Coz I am really dumb in javascript I cant make it work... instead of self.location.herf='#usrctrl', I was using window.location.href='#usrctrl'...  I think u cud figure out how dumb I am in using JavaScript...
Dont ask me how I become a webdeveloper without knowing much about JavaScript... coz I donno how I did ;) :)
 anyway I really appreciate ur help in this regard...

Steve


Karun, thanks for filling in the holes!  

In plain HTML my solution works fine, but with ASP.Net the simple HTML tag just doesn't quite cut it.  Using Javascript on postback with the bookmark tag really ties it up nicely!

Good digs.... This info can be usefull later.
Yup. This has come in handy for me a lot of times. The ability to add javascript from the code behind is a cool feature, and can be useful in more than one way. The Page class has many interesting methods, especially the Register* ones, and it is surprising what one can do with them with a little imagination!

Karun.