calling a method on the parent page from a user control
You could do what casperOne suggested, but I wouldn't advise it. This is tightly coupling your user control to your parent page, which kind of defeats the purpose of a user control.
Personally, I'd add an event to the user control (say, ButtonClicked
) that the parent page can handle. In the event handler in your parent, deal with the event however you see fit. This way you can plug the user control into a different page at a later date and not have to worry about logic in the user control that requires a specific kind of parent page.
Invoking a method from the parent page after user control has been loaded?
Get the value at a later page event:
protected override void OnLoadComplete(EventArgs e) {
x = getValueFromUserControl();
}
Unless, of course, there is a specific reason why you must get the value on Page_Load. There are other, probably more appropriate ways to handle this, but without knowing what x is and what you need to do with it, it is hard to give any other advice. For example, maybe the UserControl should fire an event that is handled by the page.
How to call javascript function in the parent page from user control?
I think if you add
ClientIdMode="static"
to your button and take out the OnClientClick="" so it looks like this:
<asp:LinkButton ID="prevItem" runat="server" ToolTip="previous" Style="color: #000000;" ClientIdMode="static"> << </asp:LinkButton>
and then use onclick directly in the javascript like this:
document.getElementById("prevItem").onclick = function SetProgressBar(){
// some logic
}
That should work...
Related Topics
Wait for an Ajax Call to Complete with Selenium 2 Webdriver
How to Debug a Single Thread in Visual Studio
How to Get the Development/Staging/Production Hosting Environment in Configureservices
Give Some Command to View in Mvvm
Yield Return Statement Inside a Using() { } Block Disposes Before Executing
How to Get Status Code from Webclient
Incorrect Stacktrace by Rethrow
Main: Not All Code Paths Return a Value
Can Structs Contain Fields of Reference Types
Transparent Background on Winforms
Automatically Start a Windows Service on Install
Receiving JSON Data Back from Http Request
Find Methods That Have Custom Attribute Using Reflection
Why Folderbrowserdialog Dialog Does Not Scroll to Selected Folder
Connecting to Oracle Database Through C#
Connecting to SQL Server with Visual Studio Express Editions
Rx: How to Respond Immediately, and Throttle Subsequent Requests