• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 4 رای - 1.75 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: مديريت منوي دايناميک
حالت موضوعی
#1
سلام. من يه منوي دايناميک دارم که از تگ هاي ul و li استفاده مي کنه و توسط جدول پر ميشه.

در اين جدول من فيلدهاي nodename، nodeurl و parentnode رو دارم.
حالا مي خوام بدونم چه جوري اين امکان رو بدم که ادمين در اين جدول اطلاعتش رو درج کنه.
. من خودم دستي در جدول مي يام مثلاً ثبت مي کنم مقالات و فرضاً دو تا آيتم به زيرمنو مي خوام اضافه کنم
مثلاً عملي، فرهنگي حالا مي يام در جدول به اين دو تا آي دي مقالات رو مي دم چون اين پدر اوناست.
خوب حالا ادمين بايد چي کار کنه يعني من بيام آيتم هاي منو (همه شاخه ها و زيرشاخه ها) رو در يک گريد ويو نشون بدم بعد يک تکست باکس بزارم که اسم آيتم جديدش رو وارد کنه و يک تکس باکس هم بزارم براي parentName و بياد اسم پدر رو در اون وارد کنه و ثبت رو بزنه به نظرتون جالبه؟ آخه من فکر مي کنم روش تميزتر و قشنگتري، کنترلهاي بهتري بايد وجود داشته باشه براي اين کار.
اميدوارم متوجه شده باشين. ببينيد يه خورده مسخره هست ايني که مي گم ولي مثلاً اگه ميشد در Treeview نشون داد اينا رو و همونجا هم رو هر کدوم از پدرها که کليک کرد مثلاً يه تکست باکس براش باز بشه و فقط اسم آيتم زيرمنو رو وارد کنه.
 
پاسخ
#2
يه سوال ديگه هم داشتم حالا اگه به اين آيتم جديد منو چه جوري مدير مي تونه يه صفحه جديد اختصاص بده؟
خودم فکر مي کنم يه صفحه به صورت فيزيکي داشته باشم مثلاً x.aspx بعد هر آيتمي که مدير اضافه مي کنه يه جوري تو اين صفحه نشون داده بشه. حالا چي بايد در url ثبت بشه؟
فکر مي کنم بايد کوئري استرينگ استفاده کنم. مثلاً موقع درج آخرين آي دي رو به دست بياريم بعد
آدرس رو به اين صورت ذخيره کنيم. x.aspx?url=id به نظرتون اين روش درستيه؟
 
پاسخ
#3
درود
دوست عزیز قوانین فروم رو بخوانید
گذاشتن لینک فروم های دیگر در فروم و منتقل کردن کاربران ممنوغ میباشد.
سوالتون اسونه من الان با موبایل وارد فروم شدم کد شما قبلا دیدم وایه اطلاعات بیشتر به لینک زبر مراجه کنید
www.articles.iauksh.ac.ir/ViewArtices.aspx?id=15753&tag=%D8%A2%D9%85%D9%88%D8%B2%D8%B4:-%D9%88%D8%B5%D9%84-%DA%A9%D8%B1%D8%AF%D9%86-%D9%85%D9%86%D9%88%DB%8C-jquery-%D8%A8%D9%87-%D8%AF%DB%8C%D8%AA%D8%A7%D8%A8%DB%8C%D8%B3-
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
#4
خيلي عذرخواهي مي کنم از نقض قوانين.
ببينيد من اون لينکي که شما معرفي کرديد رو خونده بودم. من بايند کردن اطلاعات به منو رو بلدم اگه فقط بخوام تو جدول دستي وارد کنم. ولي وقتي ادمين بخواد اين کار رو بکنه نمي دونم چه کار کنم. به نظرتون روشي که در بالا گفتم خوبه؟

راستي من قوانين سايت رو که موقع ثبت نام بايد قبول مي کرديم ذخيره کرده بودم رفتم خوندم اين موردي که شما گفتيد توش نبود. گشتم جاي ديگه قوانيني پيدا نکردم. ميشه لينکش رو بزاريد.
 
پاسخ
#5
blank_pageسلام
ساخت menu sub menu یا child menu فکر کنم گیر باشید.
اینو بگیر :
https://github.com/dotnetcurry/DynamicMenus/
یه مثال ::
Creating Dynamic Menu in ASP.net using the Menu Control by fetching the data from the databse.

Introduction
To create a dynamic menu for the website we would use ASP Menu Control, we can’t bind a Menu control directly to database data. Neither the SqlDataSource nor ObjectDataSource controls implement the IHierachicalDataSource interface. Therefore, if we want to represent database data with the Menu control, we need to perform some more work i.e. build the menu items programmatically in the Menu control. This is the approach followed here.
Imagine that you want to represent the contents of the database table with a

Menu control:
This database table represents menu items. The menu items are nested with the help Of the Parent column. For example, the customer menu item is nested under the User management as shown similarly the further nesting can also be done.

LISTING 1.1 MenuDatabase.aspx
protected void Page_Load(object sender, EventArgs e)
{
#region Page-Load-Code

if (!Page.IsPostBack)
PopulateTreeView();
#endregion
}

private void PopulateTreeView()
{

DataTable treeViewData = GetTreeViewData();
AddTopTreeViewNodes(treeViewData);
}


private DataTable GetTreeViewData()
{
// Get Menu table
string selectCommand = "SELECT Id,Parent,Description FROM MenuBarMaster";
string conString = ConfigurationManager.ConnectionStrings["ConStr"].ConnectionString;
SqlDataAdapter dad = new SqlDataAdapter(selectCommand, conString);
DataTable dtblDiscuss = new DataTable();
dad.Fill(dtblDiscuss);
return dtblDiscuss;
}

// This will Get Parent elements from the datatable i.e the root values

private void AddTopTreeViewNodes(DataTable treeViewData)
{
try
{
DataView view = new DataView(treeViewData);
view.RowFilter = "[Parent] IS NULL";
foreach (DataRowView row in view)
{
TreeNode newNode = new TreeNode(row["Description"].ToString(), row["Id"].ToString());
TreeView1.Nodes.Add(newNode);
AddChildTreeViewNodes(treeViewData, newNode);
}
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(Page, typeof(Page), "dialog", "alert('Unexpected Error');", true);

}
}


// Add child Nodes for the menu

private void AddChildTreeViewNodes(DataTable treeViewData, TreeNode parentTreeViewNode)
{
try
{
DataView view = new DataView(treeViewData);
view.RowFilter = "[Parent]=" + parentTreeViewNode.Value;
foreach (DataRowView row in view)
{
TreeNode newNode = new TreeNode(row["Description"].ToString(), row["Id"].ToString());
parentTreeViewNode.ChildNodes.Add(newNode);
AddChildTreeViewNodes(treeViewData, newNode);
}
}
catch (Exception ex)
{
ScriptManager.RegisterStartupScript(Page, typeof(Page), "dialog", "alert('Unexpected Error');", true);

}
}

Now Format Menu Control in .aspx page as shown below:
کد:
<asp:Menu ID="Menu1" runat="server" Width="236px" OnMenuItemClick="Menu1_MenuItemClick" Height="99px"><DynamicHoverStyle Font-Bold="True" Font-Names="Verdana" Font-Size="14px"/> <DynamicMenuItemStyle BackColor="#F3F3F3" BorderColor="#F3F3F3"Font-Names="Verdana" Font-Size="16px" ItemSpacing="5px" /><DynamicMenuStyle BorderColor="#F3F3F3" BackColor="#F3F3F3" /><StaticHoverStyle Font-Names="Verdana" Font-Size="14px" /><StaticMenuItemStyle Font-Bold="True" Font-Names="Verdana" Font-Size="16px" ItemSpacing="4px" /><StaticMenuStyle HorizontalPadding="5px" VerticalPadding="10px" /></asp:Menu>

The menu items are added to the Menu control in the PopulateMenu() method. This
Method first grabs a DataTable that contains the contents of the MenuMaster database table.
Next, it creates a menu item for each row that does not have a parent row (each row Where the Parent column has the value null).The child menu items for each menu item are added recursively. The Parent column is used to ....... the contents of the Menu Master DataTable.
Hope this was useful !
Thanks for reading, do let me know your comments or feedback by replying to this article.
اینم ببین :
http://www.dotnetcurry.com/ShowArticle.aspx?ID=811
این سورس هم ببین :

.zip   Article_src(pxr.ir.zip (اندازه 10.99 KB / تعداد دانلود: 6)
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


پرش به انجمن:


Browsing: 1 مهمان