Forum » Programiranje » [C#] Webpart
[C#] Webpart
mmaestro ::
Pozdravljeni,
imam sledeč problem, razvil sem user kontrolo, ki sem jo mislil hostat v smartpartu na sharepointu, ki mi je do sedaj delal lepo, vendar tukaj ko pa uporabljam modalpopup extender pa mi ne dela dobro, zato sem se odločil da bi raje prekodiral to userkontrolo v kodo in iz nje naredil navaden webpart.
Pri spodnji kodi imam par problemov:
- kako v kodi registrirati Assembly AjaxControlToolkit, kot se to naredi v userkontroli
- in pa če se kdo malo več ukvarja s temi zadevami, bi prosil če preleti kodo, in mogoče pogleda kaj sem pozabil oz naredil narobe, ker to delam prvič...
Hvala že vnaprej.
Source od userkontrole, moral dodati namesto < # ker drugače ni kazalo kode oz je javljalo napake
Code behind
Trenutna koda, iz katere bi naredil webpart:
imam sledeč problem, razvil sem user kontrolo, ki sem jo mislil hostat v smartpartu na sharepointu, ki mi je do sedaj delal lepo, vendar tukaj ko pa uporabljam modalpopup extender pa mi ne dela dobro, zato sem se odločil da bi raje prekodiral to userkontrolo v kodo in iz nje naredil navaden webpart.
Pri spodnji kodi imam par problemov:
- kako v kodi registrirati Assembly AjaxControlToolkit, kot se to naredi v userkontroli
- in pa če se kdo malo več ukvarja s temi zadevami, bi prosil če preleti kodo, in mogoče pogleda kaj sem pozabil oz naredil narobe, ker to delam prvič...
Hvala že vnaprej.
Source od userkontrole, moral dodati namesto < # ker drugače ni kazalo kode oz je javljalo napake
#%@ Control Language="C#" AutoEventWireup="true" CodeFile="Imenik.ascx.cs" Inherits="Imenik" %>
#%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
#link href="StyleSheet.css" rel="stylesheet" type="text/css" />
#asp:UpdatePanel ID="UpdatePanel1" runat="server">
#ContentTemplate>
#table>
#tr>
#td>
#asp:Label ID="Label2" runat="server" Text="Išči: ">#/asp:Label>#asp:TextBox ID="txtSearch" runat="server" >#/asp:TextBox>
#asp:Button ID="btnSearch" runat="server" Text="Button" OnClick="btnSearch_Click" Style="display:none"/>
#asp:Button ID="Button1" runat="server" Text="Button" Style="display:none"/>
#/td>
#/tr>
#tr>
#td>
#asp:Panel ID="Panel1" runat="server" Height="500px" Width="784px" CssClass="modalPopup" Style="display:none" ScrollBars="Auto">
#asp:Button ID="OK" runat="server" Text="OK" />
#asp:Button ID="Cancel" runat="server" Text="Cancel" />
#br />
#asp:GridView ID="GridView" runat="server" Height="200px" Width="720px" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False">
#FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
#RowStyle BackColor="#E3EAEB" />
#PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
#SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
#HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
#EditRowStyle BackColor="#7C6F57" />
#AlternatingRowStyle BackColor="White" />
#/asp:GridView>
#/asp:Panel>
#ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="Button1" PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="true" CancelControlID="Cancel" OkControlID="OK">
#/ajaxToolkit:ModalPopupExtender>
#/td>
#/tr>
#/table>
#/ContentTemplate>
#/asp:UpdatePanel>
Code behind
using System;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
public partial class Imenik : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
txtSearch.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.UniqueID + "').click();return false;}} else {return true}; ");
}
protected void btnSearch_Click(object sender, EventArgs e)
{
//napolnim datatable
GridView.DataSource = dt;
GridView.DataBind();
ModalPopupExtender.Show();
}
catch (Exception ex)
{
}
}
}
Trenutna koda, iz katere bi naredil webpart:
using System;
using System.Text;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using AjaxControlToolkit;
public class Imenik : System.Web.UI.WebControls.WebParts.WebPart
{
Label lblSearch;
TextBox txtSearch;
Button btnSearch;
Button Button1;
Button btnOK;
GridView GridView;
Panel Panel1;
UpdatePanel UpdatePanel1;
ModalPopupExtender ModalPopupExtender;
protected void btnSearch_Click(object sender, EventArgs e)
{
//napolnim datatable
GridView.DataSource = dt;
GridView.DataBind();
//EmptyGridFix(GridView);
ModalPopupExtender.Show();
}
catch (Exception ex)
{
}
}
protected override void CreateChildControls()
{
Controls.Clear();
// Create UpdatePanel control
UpdatePanel1 = new UpdatePanel();
// Create lblSearch control
lblSearch = new Label();
lblSearch.Text = "Išči: ";
// Create txtSearch control
txtSearch = new TextBox();
txtSearch.Text = "Išči";
// Create btnSearch control and wire its event handler.
btnSearch = new Button();
btnSearch.Text = "Išči";
btnSearch.Style.Add("DISPLAY", "none");
btnSearch.Click += new EventHandler(btnSearch_Click);
txtSearch.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearch.UniqueID + "').click();return false;}} else {return true}; ");
// Create btnOK control
btnOK = new Button();
btnOK.Text = "OK";
btnOK.Style.Add("DISPLAY", "none");
// Create btnOK control and wire its event handler.
Button1 = new Button();
Button1.Text = "Button1";
Button1.Style.Add("DISPLAY", "none");
// Create GridView control
GridView = new GridView();
GridView.ForeColor = System.Drawing.Color.FromName("#333333");
GridView.GridLines = GridLines.None;
GridView.AutoGenerateColumns = false;
GridView.CellPadding = 4;
GridView.Height = Unit.Pixel(200);
GridView.Width = Unit.Pixel(720);
// Create Panel control
Panel1 = new Panel();
Panel1.CssClass = "modalPopup";
Panel1.Height = Unit.Pixel(500);
Panel1.Width = Unit.Pixel(784);
Panel1.ScrollBars = ScrollBars.Auto;
// Create ModalPopupExtender control
ModalPopupExtender = new ModalPopupExtender();
ModalPopupExtender.TargetControlID = "Button1";
ModalPopupExtender.Enabled = true;
Controls.Add(ModalPopupExtender);
Panel1.Controls.Add(btnOK);
Panel1.Controls.Add(GridView);
UpdatePanel1.ContentTemplateContainer.Controls.Add(lblSearch);
UpdatePanel1.ContentTemplateContainer.Controls.Add(txtSearch);
UpdatePanel1.ContentTemplateContainer.Controls.Add(btnSearch);
UpdatePanel1.ContentTemplateContainer.Controls.Add(Button1);
UpdatePanel1.ContentTemplateContainer.Controls.Add(Panel1);
UpdatePanel1.ContentTemplateContainer.Controls.Add(ModalPopupExtender);
Controls.Add(UpdatePanel1);
}
protected override void Render(HtmlTextWriter output)
{
this.EnsureChildControls();
UpdatePanel1.RenderControl(output);
}
}
- spremenil: mmaestro ()
mmaestro ::
Če bo kdo imel kako minutko odveč imam še vedno problem, tako da je vsaka pomoč še vedno dobrodošla....
LP
LP
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | python -slovarOddelek: Programiranje | 3123 (2102) | Valex86 |
» | [c#]4 v vrsto - padanje krogovOddelek: Programiranje | 1988 (1820) | VASkO |
» | [ ASP.NET ] Vprašanje glede podajanja parametrovOddelek: Programiranje | 1567 (1298) | salesky |
» | [ASP.NET]Oddelek: Programiranje | 1325 (1179) | OmegaM |
» | vb.net barchartOddelek: Programiranje | 1029 (951) | rode |