I want to print the content of the label property in the Alert window.
<mx:LinkButton label="{bookmarksRepeater.currentItem.name}" click="Alert.show(this.label.toString())" />
But the Alert window is completely empty. What am I doing wrong ?
I guess the keyword "this" is referencing the application instead of the LinkButton, right ?
How can I reference the LinkButton itself, without having to add an ID to all my linkButtons ?
thanks
It doesn't work quite like Javascript. You'll have to do this:
<mx:LinkButton label="{bookmarksRepeater.currentItem.name}" click="Alert.show(event.currentTarget.label.toString())" />
That should alert the value of the label.
Related
i am using following code to popup a login panel whenever i click on some specific button.
the problem is the login panel sticks it should be non visible again if i click somewhere else on screen. Anyone got ideas how to do that.
<s:Animate id="anim" targets="{[loginPanel]}" duration="1000">
<s:SimpleMotionPath property="alpha" valueFrom="0.0" valueTo="1.0" />
<s:SimpleMotionPath property="moveByY" valueBy="2"/>
</s:Animate>
<mx:Button includeIn="Login" x="811" y="10" height="53" width="142" id="btnLoginStatus" icon="#Embed(source='assets/LogIn.jpg')" click="{ if(loginPanel.visible==true) {loginPanel.visible=false; loginPanelClicked = false;} else loginPanel.visible=true; mainViewStack.selectedIndex =0; anim.play(); loginPanelClicked = true;}" />
its all fine now add click = "loginPanelClicked = true " in bordercontainer of your login panel.
Try writing a method in a script block and link that function to the click property instead of inlining it. Can't tell from the code you provided what the method is supposed to actually do. It looks like it will play the animation regardless if the login panel is visible or not, and it will cause the login panel to always show (alpha=1.0 hint, hint).
If you write it out in a method instead of inlining it I think you'll spot your error with the else statement.
I have a jQueryUI dialog with some textboxes, plus a button. Right now, the asp:Button tag used to generate the button automatically sets its type as type="submit". The structure of the dialog is such that pressing enter at any of the textboxes should not call the button click event. It seems like the cleanest way to solve the problem, if it is doable, is to manually set the button's type to something other than submit. Is there a way to do this?
Edit: Forgot to mention this, but the button text is bound to a database item by <%# Eval() %>, which doesn't work without a server-side tag.
"
UseSubmitBehavior="false"
OnClientClick="return" />
The UseSubmitBehavior property tells ASP.NET to render as type="button" and inserts a __doPostBack() function call into the onclick property. The text of the OnClientClick property gets prepended to the client-side onclick event (with a trailing semicolon if you don't include it yourself), therefore putting return simply short-circuits the event handler and ends up doing nothing at all.
You can use just a regular html button and set it to whatever you want. It doesn't have to be a serverside asp button.
In your aspx file:
<input type="button" value="My Button" onclick="DoSomeScript();" />
I don't think you can set the Button control's AutoPostBack to false, which would normally do what you want.
In this case, I would simply not use asp:Button and just use <input type='button'>.
I'm writing a Flex application and I came across what I think is a weird problem.
I want to create a text box and a DateChooser as the datefield didn't do what I wanted and it's Halo so I can't skin it easily. I want the DateChooser to show when I click on the text input. Here is an except from my code:
<s:TextInput id="wholeDate" width="100"
mouseOver="stopChangeToNormal();"
paddingRight="10"
click="date1.visible = true"
focusOut="date1.visible = false"/>
<s:Button label="Go" width="70" />
</s:Panel>
<mx:DateChooser id="date1"
visible = "false"
change="useDate(event);"
mouseOver="changeToNormalState = false;"
y="{wholeDate.y + buttonsGroup.y + 20}"
x="{wholeDate.x + buttonsGroup.x - 175 }" />
The weird thing is that it works if I make it visible = "true" to start, but if I have it visible="false" it doesn't work! It shows, but the date I select doesn't show in the box as it does if I have it as visible="true", but I don't want it to be visible initially.
Any ideas?
I don't think its actually anything to do with the initial visibility of the DateChooser. Have you verified that your event handlers are indeed called, and in an order that makes sense? The problem appears to be that when you attempt to make a selection in the DateChooser, the TextInput gets a focusOut event, which hides the DateChooser, which apparently prevents it from receiving the selection event. I think you need to be more selective about when you actually hide the DateChooser. Perhaps you need to defer the hiding so it has a chance to respond to the selection first.
Does anybody know if it is the way to set control's child attributes properties by inline code? I mean something like that
<asp:MenuItem Text="text" NavigateUrl='<%# GetItemURL("val") %>' ></asp:MenuItem>
CodeBehind
protected string GetItemURL(string tag)
{
if (string.IsNullOrEmpty(_pageUrl))
_pageUrl = UrlManager.CastQueryString(Request.Url.ToString());
return string.Format("{0}?item={1}", _pageUrl, tag);
}
Neither of approaches work, whatever you use <%#, <%= , Page.DataBind() etc, you get an obstacle.
It would be very ugly to set such properties in code-behind.
I hope the some method allowing to set such properties in code render blocks is available
thanks in advance.
Your binding syntax is correct. You just need to make sure something is binding the parent of the <asp:MenuItem> control. You can even just run this.Page.Databind(); if there isn't a good databinding context already.
Is there a way to specify some JavaScript to execute on the OnBlur event of an ASP.NET text box? It seems to me like if I add any event handlers to the TextBox object they will just cause postbacks to the server isntead of doing what I want. Basically, I just want to be able to have the textbox be rendered in this HTML:
<INPUT type="text" onblur="alert('1234')" />
Thanks!
Could also go for:
<asp:TextBox runat="server" onblur="Javascript:alert('1234');" />
if you dont feel like setting it up in the codebehind.
Im guessing the reason why you end up with postbacks, must be because you have set AutoPostBack on the textbox to true. That makes the textbox postback when the client-side onchange event is triggered. Switch it to false, and it will act as a normal input-element.
In your codebehind, add this:
myTextBox.Attributes.Add("onblur","alert('1234');");