Web Forms :: How To Create Dynamic Link Button As Menus
Jan 12, 2010
I want to create dynamic link buttons in the asp.net code based on who logged in. For e.g. if the salespesron logged in , he should see "Customer List" and "Item Search" as menu options.
If customer logged in , it should be able to see "Customer Details" and "Item Search" as menu options.
I'm not sure how to create this dynamically in html code.
I try to serach and found the code below on this forum but it doesn't appears to create any dynamic button menu.
[Code]....
View 7 Replies
Similar Messages:
Sep 13, 2012
I want to create a menu similar to the following site
[URL]
View 1 Replies
Jul 24, 2013
im creating dynamic buttons on page load and on the click event of button1 handlere iam creating more buttons this is going fine but on click event of button 2 work is not done so how to maintain a chain of creation of button on click events
protected void Button2_Click(object sender, EventArgs e)//
{
ClientScript.RegisterClientScriptBlock(this.GetType(), ((Button)sender).ID, "<script>alert('Button_Click');</script>");
Response.Write(DateTime.Now.ToString() + ": " + ((Button)sender).ID + " was clicked");
}
protected void Button_Click(object sender, EventArgs e)//this button click will call all the items related to department
[code]....
View 1 Replies
Sep 14, 2010
I'm trying to fix a problem with some code (not written by me)
lnkbtnPageNumber.ID = "PageNumberCustomerRef" + intPageNumber.ToString();
lnkbtnPageNumber.Command += new CommandEventHandler(lnkbtnPageNumber_Command);
lnkbtnPageNumber.CommandName = "DepotRef";
lnkbtnPageNumber.CommandArgument = intPageNumber.ToString();
lnkbtnPageNumber.Text = intPageNumber.ToString().PadLeft(3, '0');
lnkbtnPageNumber.Attributes.Add("style", "margin: 2px;");
pDepotRefPages.Controls.Add(lnkbtnPageNumber);
This code creates a link button, however when I click on the button on the page. The function lnkbtnPageNumber_Command is not being called. The scripts just not getting to it.
I've tried google but everywhere I've looked says that this code should work fine.
Here is the code which is being called by the function:
void lnkbtnPageNumber_Command(object sender, CommandEventArgs e)
{
try
{
switch (e.CommandName)
{
case "GlobalID":
gintDocketNumberPage = Convert.ToInt32(e.CommandArgument);
break;
case "CreatedDate":
gintCreationDatePage = Convert.ToInt32(e.CommandArgument);
break;
case "Accounts":
gintAccountPage = Convert.ToInt32(e.CommandArgument);
break;
case "CustomerRef":
gintCustomerRef = Convert.ToInt32(e.CommandArgument);
break;
case "DepotRef":
gintDepotRef = Convert.ToInt32(e.CommandArgument);
break;
default:
gintDocketNumberPage = Convert.ToInt32(e.CommandArgument);
break;
}
I've just read somewhere that this code won't work unless called from Page_Init which if true is a but of a pain cos I can't put this fuction in Page_Init...
View 1 Replies
Oct 18, 2010
I have an ASP.Net 3.5 application with a menu. The menu is set to an xmlDataSource. The xmlDataSource is given the menus for the user as a dataset. The xmlDataSource uses an xsl transform file.Here is the code behind:
[Code]....
My problem is, when another user logs into the system, he/she gets the previous user's menus. This is based on time somehow, because if you wait long enough after another user has left a page, you'll get the proper menus.Could it have something to do with page caching? Is there something I'm missing with menus?
View 1 Replies
Feb 25, 2011
how to get the dynamic link button text on click of it.....
View 3 Replies
Mar 16, 2011
I would like to create a new Link button from code behind. Also want to fire its server side events, like its OnClick event.
View 4 Replies
Oct 31, 2010
Is there any way of using ajax confirm button for dynamically created hyper link control?
I am using data in table and each row has dynamically created link control, so if the user click on the link then it will delete the row from database. Is there any way if i can use ajax confirm button for hyper link?
View 7 Replies
Sep 27, 2010
I want to Display N-Heirarchical Menu using Dynamic Repeater Control along with CheckBoxes.
If Suppose i am having 3 level Menus i need to create 3 Repeaters Dynamically along with CheckBoxes beside of that sub Menus
View 3 Replies
Sep 2, 2010
Ok, everyone knows that the z-index is messed up in IE8 and that requires patches or workarounds...
What I can't seem to find a solution to is the white background on the DynamicMenu parts of a Menu control. Setting the background color to transparent or not setting it all doesn't seem to have any effect. This is only a problem in IE8, Firefox 3.6.8 renders the dynamic menus without the white background.
View 2 Replies
Jan 7, 2011
I have a project where I need to create menu buttons from a list in SQL Server. The problem I am having is that I need to add code to the text of those buttons. So there would be a birthday button and it should display the number of birthdays within the next two weeks or a button with the number of upcoming events.
Clarification:
There is no code yet, just some requirements. What I am doing is querying a table to get the list of buttons to display. Now each of these buttons may have dynamic text, for things like count of birthdays, events,etc... I am trying to see what the best way would be to handle this. Should I embed a snippet of code to go along with the menu item to execute when I iterate over the menu items? Maybe I should build a javascript file to go along with the code, which I add code to query a service for certain menu items?
View 4 Replies
Oct 6, 2010
I am trying to add/insert linkbutton dynamically inside gridview row, below is the code
[Code]....
Problem I facing is that the data table is getting created fine with teh linkbutton as well but the gridview is not showing the linkbutton. upon executing I am only the column which is of string type.
View 4 Replies
Dec 11, 2010
Label4.Text += "<div id ="showdiv" + i + ""> " +
" <table style=width:100%;> " +
" <input type=text style='width: 193px' id=cusno " name=cusno "
[code]...
View 10 Replies
Mar 1, 2011
I need to change a standard HTML Input button to a Link button but am running into problems because the existing
code calls a javascript function. The function basically does the same as the browser back button. When I add the code and
set the property runat="server" I get a "CS1026: ) expected".
Quite new to ASP,net (VS2010) so could be going about this the wrong way.
[Code]....
[Code]....
View 6 Replies
Jun 16, 2010
some samples for designing the menus and sub menus in html with styles and hover etc
View 8 Replies
May 30, 2010
Can we Create a link button by code behind .. means i have to create a multiple link button on a web page i want create this button dynamically from code behind
View 2 Replies
Mar 18, 2010
Does anyone out there use ComponentOne's C1Menu and create a menu with subitems at runtime? I have went through their forums and help and anything at runtime is done with C1WebMenu which was replaced with this version.I need to create the whole menu with subitems. Can you show code for this if you have?
View 1 Replies
Aug 4, 2011
Code:
//Link button
LinkButton lnk = new LinkButton();
lnk.Text = " Click Me";
//button
Button btn = new Button();
btn.Text = "Click Me";
i try put the code above to create new Link button and button but problem now is how can put the code; Response.Redirect? and how can I set the Session["ID"]?
View 16 Replies
Jan 20, 2010
I want to create a menu in a application i am building. I have 3 user roles defined in the database with menu items, navigation url and menu nesting level. I want to generate a menu based on what user logs in. I have the fetch the data from table based on user role. I am having problem in designing and binding the menu(dynamic).
View 4 Replies
Sep 24, 2010
in one of my page i need to display the menus & sub menus dynamically,for this i have a menu table called colleges & one more table called branchs 1] ABC
Science ArtsCommarce2] EFG mathszoology historylike thissome times the menus are 3some times they may be 4,5,6 may randommy incresesfor this i have the two table one is menu & sub-menus
View 2 Replies
Feb 21, 2011
create List of dynamic asp:Label, asp:textbox and asp:button when asp:dropdown selected index changed Dropdown List - ddlLang - English, Italian, French, German
If English is selected from ddlLang Create new asp:Label, asp:textbox and asp:button. If French is selected create another new asp:Label, asp:textbox and asp:button. In the same way so on.... and when button submit clicked get all dynamic text box values and label values to Save to DB.
View 3 Replies
Nov 30, 2010
how can I open a new window that contain some data without having any menu or tabs in the open new window. Basicaly, I have a linked button that I need to open in a new window that show a box with whatever information I specify without having to deal with any other thing in the open new window. ( no favoites, tools ,status bar, tool bar or links )
Also, can I control the size the location of the opened new window
View 2 Replies
Oct 27, 2010
I want to create dynamic buttons on button click event(for example., btnCreateDynamic_Click).
I tried creating dynamic buttons on page_load event and Pre_int event.They are all working but i want to create them in button click event. How can i do this in c# asp.net?
View 2 Replies
Jun 8, 2010
I'm currently writing a web app in ASP.NET MVC 1.0 (although I do have MVC 2.0 installed on my PC, so I'm not exactly restricted to 1.0) -- I've started with the standard MVC project which has your basic "Welcome to ASP.NET MVC" and shows both the [Home] tab and [About] tab in the upper-right corner. Pretty standard, right? I've added 4 new Controller classes, let's call them "Astronomer", "Biologist", "Chemist", and "Physicist". Attached to each new controller class is the [Authorize] attribute. For example, for the BiologistController.cs
[Authorize(Roles = "Biologist,Admin")]
public class BiologistController : Controller
{
public ActionResult Index() { return View(); }
}
These [Authorize] tags naturally limit which user can access different controllers depending on Roles, but I want to dynamically build a Menu at the top of my website in the Site.Master Page based on the Roles the user is a part of. So for example, if "JoeUser" was a member of Roles "Astronomer" and "Physicist", the navigation menu would say:
[Home] [Astronomer] [Physicist]
[About]
And naturally, it would not list links to "Biologist" or "Chemist" controller Index page. Or if "JohnAdmin" was a member of Role "Admin", links to all 4 controllers would show up in the navigation bar. Ok, you prolly get the idea... Now for the real question... Starting with the answer from this StackOverflow topic about Dynamic Menu building in ASP.NET, I'm trying to understand how I would fully implement this. (I'm a newbie and need a little more guidance, so please bare with me.) The answer proposes Extending the Controller class (call it "ExtController") and then have each new WhateverController inherit from ExtController.
My conclusion is that I would need to use Reflection in this ExtController Constructor to determine which Classes and Methods have [Authorize] attributes attached to them to determine the Roles. Then using a Static Dictionary, store the Roles and Controllers/Methods in key-value pairs. I imagine it something like this:
public class ExtController : Controller
{
protected static Dictionary<Type,List<string>> ControllerRolesDictionary;
protected override void OnActionExecuted(ActionExecutedContext filterContext)
{
// build list of menu items based on user's permissions, and add it to ViewData
IEnumerable<MenuItem> menu = BuildMenu();
ViewData["Menu"] = menu;
}
private IEnumerable<MenuItem> BuildMenu()
{
// Code to build a menu
SomeRoleProvider rp = new SomeRoleProvider();
foreach (var role in rp.GetRolesForUser(HttpContext.User.Identity.Name))
{
}
}
public ExtController()
{
// Use this.GetType() to determine if this Controller is already in the Dictionary
if (!ControllerRolesDictionary.ContainsKey(this.GetType()))
{
// If not, use Reflection to add List of Roles to Dictionary
// associating with Controller
}
}
}
Is this doable? If so, how do I perform Reflection in the ExtController constructor to discover the [Authorize] attribute and related Roles (if any) ALSO! Feel free to go out-of-scope on this question and suggest an alternate way of solving this "Dynamic Site.Master Menu based on Roles" problem. I'm the first to admit that this may not be the best approach.
View 2 Replies
Feb 27, 2011
am new for learning asp.net using c
View 2 Replies