Showing posts with label values. Show all posts
Showing posts with label values. Show all posts

Wednesday, March 28, 2012

changing button values on a tab

I have a AsP.net,VB.net app using tabs and I have two buttons at the bottom of the page that i want to change everytime the user goes to the next tab.

IE: btnBack and btnProceed, when you go to page two I want to change the image URL to be imageButtonBackToPage1 and imageButtonProceedToPage2 and so on, hope you get the idea.

Anyways, there are two ways for the user to go through the pages, 1 is using the tabs and 2 is using the buttons.

when the user uses the buttons i am able to change the imageurl easily but when the user uses the tabs nothing fires so I want to change the imageURl for the new page and saw that OnClientActiveTabChanged can find the active tab but I need a good example (of javascdript and HTML) of how to use this because I want to find out the active tabe and change the button images according to that.

Does anyone have good examples of how to do this? thanks.

Hi!

You could fire a post-back on Tab click using the following function, and setting the OnClientActiveTabChanged event toOnClientActiveTabChanged="ActiveTabChanged"

<script type="text/javascript">
function ActiveTabChanged(sender, e)
{
__doPostBack('<%= TabContainer1.ClientID%>', sender.get_activeTab().get_headerText());
}
</script>

Then, on code behind, use the TabContainer_ActiveTabChanged to change any values for the buttons.

Hope this helps,


thanks, what is the syntax for aclling ActiveTabChanged in the aspx page (what do you pass for sender and e?

Also, I am doing this with Ajax so I dont think the postback will work.


Hi,

Just scroll down the events drop-down list on VS 2005 and select ActiveIndexChanged on the TabContainer Control, then use the ActiveIndex or the ActivePanel properties to apply any code you need.
On server side you are not catching the javascript function, just using it as a trigger.

Why the post-back wouldn't work because AJAX? It's just firing an event which otherwise doesn't get fired by default. You can put your TabContainer inside an UpdatePanel and set the TabContainer_ActiveIndexChanged event as a trigger and you won't notice the difference. I'm using this approach and it works perfectly.


Thanks, this helps greatly, i am still learning Ajax. if you can post any sample code that would be great. thanks for your help, this saved me a lot of time.

Hi! You're welcome!

Just post your code and let us know where you are stuck, but basically is something like:

Protected Sub TabContainer1_ActiveTabChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabContainer1.ActiveTabChanged
If TabContainer1.ActiveTabIndex = 0 Then
Button1.ImageUrl = "YourPic"
ElseIf TabContainer1.ActiveTabIndex = 1 Then
Button2.ImageUrl = "YourPic"
End If
End Sub


thanks, almost there, one thing I noticed is that I had to set AutoPostBack=true for the TabContainer and now its capturing the event in the vb.net code. I thought I would be done with this task now but a funny thing is when I switch from tab to tab now its not changing the button images (i have code just like you wrote in your last post there) so I am really puzzled now, please let me know if any of you have any ideas. thanks.


Hi!

That's not a problem, just put your buttons inside UpdatePanels and call UpdatePanel.Update() from the TabContainer.ActiveIndexChanged event, or set the button's UpdatePanel triggers accordingly.


Thats it! thanks much, it works great now!


Hi! Well, I'm glad it helped!

Could you please mark the post answered to close the thread?

Cheers,

change values dependes on menus

hi, please see this page :

http://www.microsoft.com/en/us/default.aspx

in this page if i keep my mouse on menus contents are changing. like this i want to do. so what i have todo?please hosw some example link to achieve my need please

I would start with the Hover Menu, link to video below, which would allow you to handle essentially popping up the additional context.

http://www.asp.net/learn/videos/view.aspx?tabid=63&id=93


please can any one give some helpful link which relates my thread please


The last guy did give you a helpful link that relates to your thread. Here's a link to samples for that same thing:http://ajax.asp.net/ajaxtoolkit/HoverMenu/HoverMenu.aspx

The only difference between the hovermenu in the video and the one at the link you provided is content and style.

Monday, March 26, 2012

Change AJAX Slider maximum

Hi:

Is there any easy way to change the Maximum values on a slider control dynamically using Javascript.

I have an application that uses one slider to set the maximum on another slider.

Thanks for any help.

Floydo

Try this:

this.SliderExtender1.Maximum -= 2;this.SliderExtender1.Minimum += 2;// Display max and min values.this.Label1.Text =this.SliderExtender1.Maximum.ToString();this.Label2.Text =this.SliderExtender1.Minimum.ToString();

HTH

Jonathan.


Hi Floydo,

Here is an example that increase the maximum value of slider by 10 using javascript. Please try it:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="SliderExtender.aspx.cs" Inherits="AjaxToolKit_SliderExtender" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.myclass {position:relative; background:url("../images/slider_h_rail.gif") repeat-x; width:100px;height:100px;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<input type="button" value="Click" onclick="changeLength();" />
</div>
<asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged"></asp:TextBox>
<ajaxToolkit:SliderExtender BehaviorID="slider" ID="SliderExtender1" runat="server" TargetControlID="TextBox1" Minimum="0" Maximum="100" RaiseChangeOnlyOnMouseUp="true" Steps="5" RailCssClass="myclass" HandleImageUrl="../images/edit.gif">
</ajaxToolkit:SliderExtender>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></form>
<script type="text/javascript">
function changeLength()

{

var slider = $find("slider");
var max = slider.get_Maximum();
slider.set_Maximum(max + 10);

}
</script>
</body>
</html>

Hope this helps.

Saturday, March 24, 2012

CascadingDropDownList - Adding KnownCategoryValues through code

I am using several Cascading Drop Down Lists.

Is there a way that I can add values to the knownCategoryValues and category parameters that get passed to the webmethods?

For example:

[

WebMethod(EnableSession =true)]
publicCascadingDropDownNameValue[] GetSkill(
string knownCategoryValues,
string category)
{
int SubSystem_ID =int.Parse(Session["PageSubSystem"].ToString());
StringDictionary kv =CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);

int Location_ID;
if (!kv.ContainsKey("Location") || !int.TryParse(kv["Location"],out Location_ID))
{
returnnull;
}

Sorry for the badly formatted code, but the Code Entry thing is not working.

Anyway, how would I add a "Key" of Location to the parameters? Would this have to be in the WebService, or can I add it from the web page?

Any help on this would be greatly appreciated!

Try to take a look at the following link about how to useAjax:CascadingDropDown with a Database for reference.
http://ajax.alpascual.com/Walkthrough/CCDWithDB.aspx
Wish this can help you.

CascadingDropDown: Pulling selected values from a cookie

I am using the CascadingDropDown extender from the AjaxControlToolkit and I was wondering if there was an easy way to set the selected value and to populate child drop downs when the page loads. I am storing a users previous selections in a cookie so when they start a new form these values are already selected. I did some looking at the CascadingDropDown code but I didn't see an easy way to accomplish this. Does anyone know an easy way to do it?

Or am I going to have to cobble some JS together to make it happen?

Thanks.

Derek

Couldn't you just do something like

myCascadingDropdownListExtender.SelectedValue = Request.Cookies("MyCookie")

on Page_Load ? It works for me.

CascadingDropDown, problems selecting values

Hello,

I did some research but couldn't find a solution and I hope you can help me.
The DropDownList (there are more, but one will suffice) is populated correctly, at least when I click on it.

<asp:HiddenField ID="SomeID" OnValueChanged="VC_Method" runat="server" />
<div id="hiddenForm" style="display :none">
<asp:UpdatePanel ID="DetailUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="False" runat="server">
<ContentTemplate>
<asp:DropDownList ID="ProjectDDL" runat="server"></asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CDD0" TargetControlID="ProjectDDL" Category="Project" ServicePath="CDD.asmx" ServiceMethod="GetProjects" runat="server" />

So now what this should do is, when clicking on a Link the DetailUpdatePanel becomes visible and the VC_Method of the HiddenField is executed and in this Method I want to select a certain item of the DDL. But there are no values to choose from. Now my question is, becomes the CDD only populated when I click on it and if so, how can I populate it beforehand?

Thanks in advance.

I solved the problem above, but I'm now terribly stuck.

After the user selected one item from the first dropdownlist, the second becomes active etc. Now the user decides to cancel the task and for wathever reason he starts anew. My problem now is, that I want to reset the cascading dropdownlist on client side, so that the user can only select items from the first dropdownlist. For this purpose a javascript function should be executed. I can set the dropdownlist to the value I want and also the cascading dropdownlist, but it won't affect the second and third. Thus they stay active with wrong information.

I have tried now for one day hand havn't got a clue. Please help me..

EDIT:corrected some errors


Hi Twinkybot,

My understanding of your issue is that you want the second CascadingDropDown not change while you selected the first CascadingDropDown. If I has misunderstood, please feel free to let me know.

Based on this knowledge, I think you can remove the handlers of the first CascadingDropDown and then remove the second CascadingDropDown's _parentChangeHandler. Here is the sample.

<%@. Page Language="C#" EnableEventValidation="false" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
<script runat="server"
protected void Page_Load(object sender, EventArgs e)
{

}
</script
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="../WebService/CityServiceOledb.asmx" InlineScript="true" />
</Services>
</asp:ScriptManager>
State:<asp:DropDownList runat="server" ID="dlState">
</asp:DropDownList>
City:
<asp:DropDownList runat="server" ID="dlCity" AutoPostBack="true">
</asp:DropDownList>

<cc1:CascadingDropDown ID="CascadingDropDown1" BehaviorID="myCDEState" runat="server" TargetControlID="dlState"
Category="State" ServicePath="../WebService/CityServiceOledb.asmx" ServiceMethod="GetStates" LoadingText="[Loading...]" PromptText="Please select state" UseContextKey="true" ContextKey="0,0">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown2" BehaviorID="myCDECity" runat="server" TargetControlID="dlCity" ParentControlID="dlState"
Category="City" PromptText="Select a city" ServicePath="../WebService/CityServiceOledb.asmx"
ServiceMethod="GetCities" LoadingText="Load Text..." >
</cc1:CascadingDropDown>

<input id="Button2" type="button" value="remove" onclick="removeCascading();"/>
<asp:Button ID="Button1" runat="server" Text="Button" />

<script type="text/javascript" language="javascript">
function removeCascading(){
$find("myCDEState").dispose();
$removeHandler($find("myCDECity")._parentElement, "change", $find("myCDECity")._parentChangeHandler);
$get("Button2").disabled = true;
}
</script>
</form>
</body>
</html>

Best regards,

Jonathan


Yes, I think you misunderstood. I want the second and third CascadingDropDown to change according to the selcetion of the first. But the Problem is, that it doesn't.

I try to explain my problem better. The user selects one item in the first DropDownList. The second becomes updated and the user is able to select one item. Now he cancels the changes and restarts the procedure.

What I want now is, that after hitting the cancel-Button, the DropDownLists must reset. I.e. in a Javascript I set the selectedIndex for the first DropDownList to 0. Corresponding to this selection the second and third should now change themselves, but it doesn't happen.

<asp:DropDownList ID="ProjectDropDownList" runat="server"></asp:DropDownList><ajaxToolkit:CascadingDropDown ID="CascadingDropDown0" TargetControlID="ProjectDropDownList" Category="Project" PromptText="Foo" ServicePath="~/CDD.asmx" ServiceMethod="GetProjects" runat="server" /><asp:DropDownList ID="TaskDropDownList" runat="server"></asp:DropDownList><ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" TargetControlID="TaskDropDownList" ParentControlID="ProjectDropDownList" Category="Task" PromptText="Foo" ServicePath="~/CDD.asmx" ServiceMethod="GetTaskForProject" runat="server" /> <asp:DropDownList ID="TaskShortDescriptionDropDownList" runat="server"></asp:DropDownList><ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" TargetControlID="TaskShortDescriptionDropDownList" ParentControlID="TaskDropDownList" Category="TaskDescription" PromptText="Foo" ServicePath="~/CDD.asmx" ServiceMethod="GetDescriptionForTask" runat="server" />
function clearForm(){ var projectDDL = document.getElementById('<%= ProjectDropDownList.ClientID%>'); projectDDL.selectedIndex = 0; //Here must be something to activate the cascade}

I found a solution and I will post this for other desperate people.

projectDropDownList.options[0] = new Option(projectName, projectId, true, false);
taskCascade._onParentChange(null, false);

CascadingDropDown set value

Hi,
I am new to ASP.NET and I have a question regarding the CascadingDropDown Ajax control. Can you set the dropdown list to one of the values instead of "please select etc"?
Thanks.

You should be able to set the LoadingText and the PromptText properties of the CascadingDropDown control to say anything you want.

Regards,

Scott Lance
Application Developer
Children's Miracle Network

Wednesday, March 21, 2012

CascadingDropDown persistent Values

Hi,i have 3 dropdownlist, using atlas cascadingdropdown. Every think works fine, but when i click in a button( this button only set the enable=true to all control in the page) occurs an postback, then when the page is load the dropdown loser the previos selected values..

the method to populate the dropdown are in the if(!Ispostback)...how can i fix that??

Try setting the SelectedValue property of the CDDs in the button handler.

hi, thanks for the reply but i have already tryied that and dont work...

bye,

marcos


Please reply with acomplete, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

CascadingDropDown List 1-dimensional array error

I'm trying to get the CascadingDropDown from the Atlas toolkit to work with a database. I receive this error at the lineReturn values.ToArray().

Error 1 Value of type '1-dimensional array of AtlasControlToolkit.CascadingDropDownNameValue' cannot be converted to 'AtlasControlToolkit.CascadingDropDownNameValue'

Here is the WebMethod.

<WebMethod()> _

PublicFunction GetMakes(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue

Dim makeAdapterAs CarsTableAdapters.MakeTableAdapter =New CarsTableAdapters.MakeTableAdapter()

Dim makesAs Cars.MakeDataTable = makeAdapter.GetMakes()

Dim valuesAs List(Of CascadingDropDownNameValue) =New List(Of CascadingDropDownNameValue)()

ForEach drAs DataRowIn makes

Dim makeAsString =CStr(dr("Make"))

Dim makeIdAsInteger =CInt(dr("MakeID"))

values.Add(New CascadingDropDownNameValue(CStr(dr("Make")), dr("MakeID").ToString()))

Next dr

Return values.ToArray()

EndFunction

Any Ideas?

Rgds

Dave

Replace

PublicFunction GetMakes(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue

With

PublicFunction GetMakes(ByVal knownCategoryValuesAsString,ByVal categoryAsString)As CascadingDropDownNameValue()

CascadingDropDownNameValue() is an array, butCascadingDropDownNameValue is not


Thanks lotusinriver. It works perfectly now.

Dave


You are very welcome.