0

I'm setting up a Web User Control in ASP 4. The control itself works correctly, and the code for the onload even is the same as used in my standard aspx pages.

protected void GetTranslationImage(object sender, EventArgs e)
                {
                        ImageButton image = (ImageButton)sender;
                        objTranslation = new TranslationsHelper();
                        string sTranslationID = image.ImageUrl.ToString();
                        string lang = ((NRMaster)this.Master).Language;
                        lang = lang == null ? "en-gb" : lang;
                        image.ImageUrl = objTranslation.GetTranslation(sTranslationID, lang);
                }

When the object is passed through onLoad it doesn't contain the default URL during GetTranslationImage. The object changes to the translation required however it reverts back following in the HTML on the page load.

The definition of the ImageButton is as follows:

<asp:ImageButton ID="btnSearch" runat="server" name="Search" value="Search" class="Search" src="/_resources/img/BTN_search.gif" onclick="btnSearch_Click" onLoad="GetTranslationImage" />

Does the control alter the time this function needs to be run.

Any help would be greatly appreciated.

Thank You James

2 Answers 2

1

Why are you setting src="/_resources/img/BTN_search.gif" if you are overwriting it in OnLoad?

1: Remove it

Or

2: Change it to:

ImageUrl="/_resources/img/BTN_search.gif"
Sign up to request clarification or add additional context in comments.

2 Comments

It is so the translation routine knows what to translate. Also it stays as default if no translation is needed, so just removing it isn't actually an option
But then change it to ImageUrl instead of src. I believe that "src" setting is the reason you are not able to over-write the ImageUrl
0

What if you made the transition method public from within the usercontrol and you simply call out to that method in your page load?

page_load()
{
   myusercontrol.StartImageTransition();
}

Public Methods inside User control c# .net

1 Comment

Thanks, but after further investigation the object isn't populated on onLoad. I can't get access to any defaults and I can't set any of the object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.