Showing posts with label menu. Show all posts
Showing posts with label menu. Show all posts

Saturday, March 24, 2012

asp.net 2.0 ajax website menucontrol : javascript error :"Microsoft JScript runtime error:

i m developing application using ajax in asp.net 2.0 . I m using menu control of asp.net,multiview and view control.while running this application i got error "Microsoft JScript runtime error: '0.cells' is null or not an object" so now what is the solution of this i have returend following coad in html

<

div>

<

asp:UpdatePanelID="UpdatePanel2"UpdateMode="Conditional"runat="Server"><ContentTemplate>

<tablecellpadding="0"cellspacing="0"border="0"width="100%"><tr><tdwidth="6%"><asp:MenuID="Menu1"runat="server"DynamicHoverStyle-BackColor="Aqua"DynamicHoverStyle-Font-Overline="true"DynamicHoverStyle-ForeColor="Brown"DynamicMenuItemStyle-BackColor="Crimson"dOrientation="Horizontal"StaticEnableDefaultPopOutImage="False"OnMenuItemClick="menu_click"Orientation="Horizontal"><Items><asp:MenuItemText="Operator"Value="0"></asp:MenuItem><asp:MenuItemText="Visitor"Value="1"></asp:MenuItem></Items><StaticMenuStyleBackColor="White"/><StaticMenuItemStyleBackColor="White"/><StaticSelectedStyleBackColor="#FFC080"/><StaticHoverStyleBackColor="#80FFFF"/></asp:Menu><asp:MultiViewID="MultiView1"runat="server"><asp:ViewID="op"runat="server"><tablewidth="30%"><trvalign="top"><td>hetal</td></tr></table></asp:View><asp:ViewID="visitor"runat="server"><tablewidth="30%"><trvalign="top"><td>tarun</td></tr></table></asp:View></asp:MultiView></td>

</tr>

</table>

</ContentTemplate>

</

asp:UpdatePanel>

</

div>

please give me solution for this error...thank u

<asp:menu > control seems to be not compatible withUpdatepanel. Put the menu control outside the updatepanel. If you wantto refresh only updatepanel contents on click of menu control, then setmenu control as an async postback trigger for updae panel as givenbelow.

try following modified code.

<div>
<asp:Menu ID="Menu1"runat="server" DynamicHoverStyle-BackColor="Aqua"DynamicHoverStyle-Font-Overline="true"DynamicHoverStyle-ForeColor="Brown"DynamicMenuItemStyle-BackColor="Crimson" dOrientation="Horizontal"StaticEnableDefaultPopOutImage="False" OnMenuItemClick="menu_click"Orientation="Horizontal">
<Items>
<asp:MenuItem Text="Operator" Value="0" ></asp:MenuItem>
<asp:MenuItem Text="Visitor" Value="1"></asp:MenuItem>
</Items>
<StaticMenuStyle BackColor="White" />
<StaticMenuItemStyle BackColor="White" />
<StaticSelectedStyle BackColor="#FFC080" />
<StaticHoverStyle BackColor="#80FFFF" />
</asp:Menu>
<asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" runat="Server">
<ContentTemplate>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="6%">
<asp:MultiView ID="MultiView1" runat="server" >
<asp:View ID="op" runat="server">
<table width="30%">
<tr valign="top"><td>hetal</td></tr>
</table>
</asp:View>
<asp:View ID="visitor" runat="server">
<table width="30%">
<tr valign="top"><td>tarun</td></tr>
</table>
</asp:View>
</asp:MultiView>
</td>
</tr>
</table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Menu1"EventName="MenuItemClick" />
</Triggers>
</asp:UpdatePanel>

</div>


You can also add the below script to your aspx page. It overrides the AJAX function and takes care of the error. This works for problems with Tab Controls too, seehttp://forums.asp.net/thread/1628780.aspx.

<scripttype="text/javascript">

var oldMenu_HideItems = Menu_HideItems;if(oldMenu_HideItems)

{

Menu_HideItems =

function(items)

{

if (!items || ((typeof(items.tagName) =="undefined") && (itemsinstanceof Event)))

{

items = __rootMenuItem;

}

if(items && items.rows && items.rows.length == 0)

{

items.insertRow(0);

}

return oldMenu_HideItems(items);

}

}

</script>

ASP not working inside of Accordian.

I am having an issue I am using an accordian sort of like a popup more options menu. I added some drop down boxes inside an accordian and it displays fine and shows the values. But when I try to build a function to send the drpVariable.SelectedValue is set to null. It seems that the default.aspx.cs does not capture the selected value inside the accordian. Does anyone know a work around this? Below is an example of some of the code

<

cc1:AccordionID="Accordion1"runat="server"AutoSize="Limit"style="z-index: 101; left: 845px; position: relative; top: -349px"Height="370px"Width="134px"><Panes><cc1:AccordionPaneID="dummy"runat="server"></cc1:AccordionPane><cc1:AccordionPaneID="apMsgSearchOptions"runat="server"><Header><ahref=""onclick="return false;">Search Options</a></Header></cc1:AccordionPane><cc1:AccordionPaneID="apMsgAdvancedSearch"runat="server"><Header><ahref=""onclick="return false;">Advanced Search</a></Header><Content><asp:LabelID="lblMsgKeyClient"runat="server"Text="Client"/><br/><asp:TextBoxID="txtMsgKeyClient"Width=45pxEnabled="false"MaxLength="5"runat="server"/><br/><asp:LabelID="lblMsgKeyStartDate"runat="server"Text="Start Date"/><br/><asp:TextBoxID="txtMsgKeyStartDate"Width=45pxEnabled="false"runat="server"/><br/><asp:LabelID="lblMsgKeyEndDate"runat="server"Text="End Date"/><br/><asp:TextBoxID="txtMsgKeyEndDate"Width=45pxEnabled="false"runat="server"/><br/><asp:LabelID="lblMsgKeyMsgCategory"runat="server"Text="Msg Category"/><br/><asp:DropDownListID="drpMsgKeyMsgCategory"runat="server"Width="50px"><asp:ListItemSelected="True"></asp:ListItem><asp:ListItem>A</asp:ListItem><asp:ListItem>B</asp:ListItem><asp:ListItem>C</asp:ListItem><asp:ListItem>D</asp:ListItem><asp:ListItem>E</asp:ListItem><asp:ListItem>F</asp:ListItem><asp:ListItem>Z</asp:ListItem><asp:ListItem>1</asp:ListItem><asp:ListItem>2</asp:ListItem><asp:ListItem>3</asp:ListItem><asp:ListItem>4</asp:ListItem></asp:DropDownList><br/><asp:LabelID="lblMsgKeyMsgType"runat="server"Text="Message Type"/><br/><asp:DropDownListID="drpMsgKeyMsgType"runat="server"Width="75px"><asp:ListItemSelected="True"Value="H">Hour</asp:ListItem><asp:ListItemValue="5">5 Min</asp:ListItem><asp:ListItemValue="1">1 Min</asp:ListItem></asp:DropDownList><br/><asp:LabelID="lblMsgKeyProductCode"runat="server"Text="Product Code"/><br/><asp:DropDownListID="drpMsgKeyProductCode"runat="server"Width="75px"><asp:ListItemSelected="True"></asp:ListItem><asp:ListItem>DMS</asp:ListItem><asp:ListItem>RTDS</asp:ListItem><asp:ListItem>XMLM</asp:ListItem></asp:DropDownList><br/><asp:LabelID="lblMsgKeyRequestType"runat="server"Text="Request Type"/><br/><asp:DropDownListID="drpMsgKeyReqType"runat="server"Width="75px"><asp:ListItemSelected="True"></asp:ListItem><asp:ListItemValue="A">Alpha</asp:ListItem><asp:ListItemValue="E">Event</asp:ListItem><asp:ListItemValue="I">Inquire</asp:ListItem><asp:ListItemValue="M">Maint</asp:ListItem><asp:ListItemValue="P">Publish</asp:ListItem><asp:ListItemValue="-">Error</asp:ListItem></asp:DropDownList><br/></Content></cc1:AccordionPane>

Just an update I added a dropdown reading an XML file... and all the drop down boxes worked then. Can anyone explain why it now works and didnt without when all the dropdown had list items.

ASP Menu Control & AJAX Tab Control

Hi,

I have a menu control on my master pages. When I click on a menu I would like the Tabs on the Tab Control to change accordingly.

How do I go about in doing this? The Tab Control is on the ContentPlaceHolder (Default.aspx).

Thanks much appreciated.

Any1 Please !!!!

i have same problem..smbdy please help!!


This is what I have so far ......!!!

Im accessing the TabControl on the Default.aspx & this code does not work. I get NO errors thou. Am I doing something wrong?

protectedvoid MenuItem_Click(object sender,MenuEventArgs e)

{

if (this.Menu1.SelectedItem.Value.Equals("1"))

{

TabContainer myTabContainer = (TabContainer)this.ContentPlaceHolder1.FindControl("TabContainer1");

TabPanel myTabPanel2 = (TabPanel)this.ContentPlaceHolder1.FindControl("TabPanel2");

myTabContainer.ActiveTab = myTabPanel2;

}

}


I would like to change the tabs on the client side with no post backs. Any1 knows of a javascript that can help with this?

Please peeps....... Im willing to pay for this answer !!

Any Master minds out their ?


Here you go ,

<scriptlanguage="javascript">function changeTab( tabIndex ){var tabBehavior = $get('<%=TabContainer1.ClientID%>').control;

tabBehavior.set_activeTabIndex(tabIndex);

}

</script>

Remember to mark my reply as the answer .!!!

Happy coding !!!


Thanks sooooooooo much !!!

How do I add this function to a click event on the asp.net menu control.


Please note that Tab Control is on Default.aspx & Menu control is on MasterPage

Hi,

To solve this problem use AJAX Control Toolkit.

Use TabPanel toolkit in that.I think this will help u.


I am using the AJAX TabControl what do you mean?

Does any1 know how I can add this if the asp menu is on the master pages & the TabControl is on the ContentPlaceHolder (Default.aspx).

This function should fire every time a link is clicked on the menu.

<scriptlanguage="javascript">

function changeTab( tabIndex ){

var tabBehavior = $get('<%=TabContainer1.ClientID%>').control;

tabBehavior.set_activeTabIndex(tabIndex);

}

</script>


Here is how I would approach this.

In the code-behind for Default.aspx, I would emit a javascript function like your changeTab one, but I would call it

Menu1_MenuItemClicked_Listener

It would take a parameter indicating the menu item that was clicked. This could be a number, name or whatever you would use to distinguish between menu items. Your function would make the appropriate tab active based on the menu item that was clicked.

In the HTML of the master page, I would add a function like so:

<script>

function Menu1_MenuItemClicked(menuItem)

{

if (Menu1_MenuItemClicked_Listener)

Menu1_MenuItemClicked_Listener(menuItem);

}

</script>

Essentially, if your content page has defined a listener, it will be invoked. If not, no worries.

Then, in the code behind of the master page, I would add an attribute to each menu item like so:

MenuItem1.Attributes["onclick"] = "javascript: Menu1_MenuItemClicked('menuItem1');";

This will cause the menu item to invoke the master page's event handler.

I would also change the menu item's href to "javascript: return false;" so it doesn't invoke a postback.


HI, Thanks for the help.

Am I doing this right as im getting errors. I added this line to the Menu1_MenuItemClick event of the menu control like this.....

protected

void Menu1_MenuItemClick(object sender,MenuEventArgs e)

{

MenuItem1.Attributes["Item1"] = "javascript: Menu1_MenuItemClicked('menuItem1');";

}

Another thing, How does the script function nows what tab to change to ?