|
Hi,
Yes you can use this code .. but it will be better to develop your own code .. as you can do this without using graphics(GDI+).
Just create a table from the datagrid (Generate DataTable) and use it
I hope it works,
THanks
Sushant Duggal.
Sushant Duggal.
|
|
|
|
|
Hai
I would like to use a free open source Data Block in my Web project. Can anyone suggest some good and excellent among them.
Thanks in advance
|
|
|
|
|
|
Hi
I have 3 frames Left, top and main content area - is there a way to force refresh of the left frame from the main content frame?
(all frames have a .aspx page)
thanks in advance!
|
|
|
|
|
try this
parent.leftFrame.window.location.reload();
Nav.
|
|
|
|
|
Does it support reload(), I am not sure, but I used to do something like this..
window.parent.frames[0].location.href='yourleftframe src.html'
|
|
|
|
|
Hi
I created a master page and put a treeview control in there on the left side table layout want to use the right side for different pages.
but the problem is i have a textbox and search button above the treeview and the treeview is loaded depending on what search string you type in. then i can click on a treenode and click a button on the top menu called addSubTreeNode - the right content panel should have a few text boxes for adding details of this TreeNode - but when i do this the treeview disappears - i want it to stay how it was on the mainpage.aspx - even when i goto this new addsubtreenode.aspx for adding a subTreeNode. (sort of like if i had frames and the treeview page remained the same - i want it to be in the same state as it was on mainpage.aspx when i natigate to addsubtreenode.aspx) (both these aspx pages are derieved from the master page and the treenode code is on the masterpage)
is this possible without frames?
thanks
-- modified at 19:14 Sunday 9th July, 2006
|
|
|
|
|
Hi,
I ran into this problem for the first time since I was working with .Net framework. You can't get (directly) to the query string of the page if your aspx is contained into a frame. It's possible to get it though the UrlRefferer object and to parse out the string.
My question is if you know some other way...
Appreciate it,
Cheers
|
|
|
|
|
Add the querystring to the URLs in the frame tags in the code in the frameset page.
---
b { font-weight: normal; }
|
|
|
|
|
Hey!
I am using framework 2.0 membership to handle my users on a site.
It is posible to get information like name, isInRole and so on. But i need to also get the id nr of the current user.
ex
Page.User.Identity.Name
I do not want to go to the mySQL server every time i need the id of a user, it shold be placed in session or cookie the same way the name is.
Is this posible? and if, how?
I am using a mySQL provider, what function is the mebership using to logon i user?
Best Regards
Jimmy
|
|
|
|
|
Hi,
I have a C# library created under VS2003 and stored in VSS. I now would like to create a version of that library targeted for the APS.NET 2.0 runtime under VS2005 but I am unable to figure out how to set things up so I can use one codebase stored in VSS. Does anyone have a suggestion on how best to maintain one body of code but compile two separate versions?
Thanks,
Rick
|
|
|
|
|
I'm not absoutely sure, but don't think it's possible - there are many MANY differences between 1.1 & 2 - just convert a project from one to the other and see the output report
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Richard,
Thanks for the reply. I haven't found any way yet either to share teh code between teh two solutions. But I DID find one interesting hack that will allow VS2005 to compile to 1.1 so you could in effect use the same solution to compile versions of both. For those that are interested, here's the URL:
http://blogs.msdn.com/jomo_fisher/archive/2005/04/22/410903.aspx[^]
Rick
|
|
|
|
|
hi all,
i have created an custom server control that is rendered, i.e., not a composite control that is built in CreateChildControls() . My control extends WebControl and i have wired up the ClientScript.GetPostBackEventReference() but this doesnt work if javascript is disabled, obviously.
so i also wired up the Click event of the buttons in my control as a failsafe, but they never fire. can anyone please help with this.
the control is huge, so i will try and post the relevant code below.
the control is a message box and i only need to be concerned with the button click events.
protected override void OnInit(EventArgs e)
{
if (Draggable)
{
Page.ClientScript.RegisterClientScriptInclude(
this.GetType(), "DragScript", Page.ClientScript.GetWebResourceUrl(this.GetType(),
"WebMessageBox.Resources.DragScript.js"));
}
RenderEmbeddedStyleSheet(null);
foreach (Button button in Buttons)
{
button.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(this, button.Text);
button.Click += new EventHandler(Button_Click);
}
}
#region ButtonClicked event
protected void Button_Click(object sender, EventArgs e)
{
OnButtonClicked(new ButtonClickedArgs((Button)sender));
}
public delegate void ButtonClickedHandler(MessageBox sender, ButtonClickedArgs e);
[
Description("Fired when a button is clicked within the Message Box"),
Category("Button")
]
public event ButtonClickedHandler ButtonClicked;
protected void OnButtonClicked(ButtonClickedArgs e)
{
if (ButtonClicked != null)
{
ButtonClicked(this, e);
this.Visible = false;
}
}
#endregion
#region IPostBackEventHandler Members
public void RaisePostBackEvent(string eventArgument)
{
bool found = false;
Button button = null;
int i = 0;
while (i < Buttons.Count && !found)
{
Button b = Buttons[i];
if (b.Text == eventArgument)
{
found = true;
button = b;
}
i++;
}
if (button != null)
{
OnButtonClicked(new ButtonClickedArgs(button));
}
}
#endregion
kind regards,
g00fy
|
|
|
|
|
Hi there,
Does your custom control implement the INamingContainer interface in order for the postback event Click to be routed to the child button control?
|
|
|
|
|
yes it does,
public class MessageBox : WebControl, INamingContainer, IPostBackEventHandler
as posted earlier i am, adding the event handler in oninit(), do i also need to wire up the event in AddParsedSubObject() ?
regards,
g00fy
|
|
|
|
|
How do you add the child buttons stored in the Buttons collection? Do they get declared between the opening and closing tags of the custom control in the web page? or do you dynamically declare somewhere else?
|
|
|
|
|
the buttons are decalred in a button collection.
initially the button collection is instantiated like this
private ButtonCollection m_Buttons = new ButtonCollection();
[
PersistenceMode(PersistenceMode.InnerProperty),
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
Editor(typeof(ButtonCollectionEditor), typeof(UITypeEditor)),
Category("Message Box"),
Description("The buttons that will appear on the Message Box"),
NotifyParentProperty(true),
RefreshProperties(RefreshProperties.All),
Bindable(true)
]
public ButtonCollection Buttons
{
get { return m_Buttons; }
}
in the MessageBox class. There is also an enum to designate a predifned set of buttons that works like this
private MessageBoxType m_MessageBoxButtons = MessageBoxType.YesNoCancel;
[
Category("Message Box"),
Description("The pre-defined type of Message Box you want to start with."),
DefaultValue(MessageBoxType.YesNoCancel),
Bindable(true),
NotifyParentProperty(true)
]
public MessageBoxType MessageBoxButtons
{
get { return m_MessageBoxButtons; }
set
{
m_MessageBoxButtons = value;
Button[] buttons = null;
Button button = null;
switch (m_MessageBoxButtons)
{
case MessageBoxType.YesNoCancel:
buttons = new Button[3];
button = new Button();
button.ID = "YesButton_" + DateTime.Now.Millisecond;
button.Text = "Yes";
buttons[0] = button;
button = new Button();
button.ID = "NoButton_" + DateTime.Now.Millisecond;
button.Text = "No";
buttons[1] = button;
button = new Button();
button.ID = "CancelButton_" + DateTime.Now.Millisecond;
button.Text = "Cancel";
buttons[2] = button;
m_Buttons = new ButtonCollection(buttons);
break;
case MessageBoxType.YesNoAbort:
buttons = new Button[3];
button = new Button();
button.ID = "YesButton_" + DateTime.Now.Millisecond;
button.Text = "Yes";
buttons[0] = button;
button = new Button();
button.ID = "NoButton_" + DateTime.Now.Millisecond;
button.Text = "No";
buttons[1] = button;
button = new Button();
button.ID = "AbortButton_" + DateTime.Now.Millisecond;
button.Text = "Abort";
buttons[2] = button;
m_Buttons = new ButtonCollection(buttons);
break;
case MessageBoxType.Custom:
Buttons.Clear();
break;
}
}
}
then in OnInit() i wire up the events like this, i also tried wiring up the event for the buttins during render, but that didnt work either.
protected override void OnInit(EventArgs e)
{
if (Draggable)
{
Page.ClientScript.RegisterClientScriptInclude(
this.GetType(), "DragScript", Page.ClientScript.GetWebResourceUrl(this.GetType(),
"WebMessageBox.Resources.DragScript.js"));
}
RenderEmbeddedStyleSheet(null);
foreach (Button button in Buttons)
{
button.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(this, button.Text.Trim());
button.Click += new EventHandler(Button_Click);
}
}
the ButtonCollection class extends CollectionBase and overrides the standard functions (add, this[int], delete, clear etc) so it is strongly typed.
kind regards,
g00fy
|
|
|
|
|
There are a couple of things come to mind:
+ This code below makes the button's id not consistent:
button.ID = "NoButton_" + DateTime.Now.Millisecond;
so the event cannot be routed to the button properly.
+ Do you add these buttons to the parent custom control?
+ You have another option to fire up the custom event of the control by overriding the OnBubbleEvent method to capture the button's click event, then you can raise the custom event.
|
|
|
|
|
hey thanx for all your help
i didnt notice that ID property, that was redundant from something else i had done earlier.
I have made the following changes;
- fixed the buttosn ID property
- added each buttons to base.Controls (base == WebControl)
- overriden OnBubbleEvent()
i have left the call to base in the bubble event and tried to step through it but it never fires, any ideas.
protected override void OnInit(EventArgs e)
{
if (Draggable)
{
Page.ClientScript.RegisterClientScriptInclude(
this.GetType(), "DragScript", Page.ClientScript.GetWebResourceUrl(this.GetType(),
"WebMessageBox.Resources.DragScript.js"));
}
RenderEmbeddedStyleSheet(null);
foreach (Button button in Buttons)
{
base.Controls.Add(button);
button.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(this, button.Text.Trim());
button.Click += new EventHandler(Button_Click);
}
}
protected override bool OnBubbleEvent(object source, EventArgs args)
{
return base.OnBubbleEvent(source, args);
}
btw when i get it going, do you need an ASP.NET 2.0 MesageBox control?
kind regards,
g00fy
|
|
|
|
|
ok went back to basics (and my asp books) and discovered this;
this does not work
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebMessageBox
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:TestParent runat=server></{0}:TestParent>")]
public class TestParent : Control, INamingContainer
{
private Button button = new Button();
protected override void OnInit(EventArgs e)
{
button.Text = "New Button";
button.ID = base.UniqueID;
button.Click += new EventHandler(button_Click);
}
protected override void Render(HtmlTextWriter writer)
{
base.Controls.Add(button);
base.Render(writer);
}
void button_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
string s = button.Text;
}
}
}
this does work
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebMessageBox
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:TestComposite runat=server></{0}:TestComposite>")]
public class TestComposite : WebControl, INamingContainer
{
void button_Click(object sender, EventArgs e)
{
Button button = (Button)sender;
string s = button.Text;
}
protected override void CreateChildControls()
{
Button button = new Button();
button.Text = "New Button";
button.ID = base.UniqueID;
button.Click += new EventHandler(button_Click);
base.Controls.Add(button);
}
}
}
any ideas on getting a rendered control to fire server events, otherwise i will have to rewrite my render code into CreateChildControls()?
kind regards,
g00fy
|
|
|
|
|
have changed my control to a composite control and all is good.
regs,
g00fy
|
|
|
|
|
The first case does not work as you add the dynamic button in the Render method which occurs after the postback event is processed in the control life cycle, so the event hanler does not execute. In the second case, you use the CreateChildControls method to add the child control, and this method makes sure that the child button is added to the control hierarchy before the postback event is processed, so it works. Generally speaking, you need to make sure that the child control is added to the parent (more general, the control hierarchy) and the handler is wired up to the event before the event is processed in order to make it run properly.
|
|
|
|
|
thanks for all your help so far,
the trouble i am having now is that the control is not rendered design time properly when it is a composite control, the properties are not being refreshed, like when i set a button group to YesNoCancel, i get nothing until i switch from design to source view to deign again.
so i moved the logic to create control hierarchy into createchildcontrols() then in render i just render the table that createchildcontrols() creates. but now the events aren't firing again and i can't see why as the events are wired up in CreateChildControls() still.
any ideas on how i can get design time support refreshing display when i change a property or
sorry to be a pain.
kind regards,
g00fy
this is what i have now
private WebTable MessageBoxTable = null;
private WebTable BuildHierarchy()
{
WebTable table = new WebTable(1, 1);
table.Style[HtmlTextWriterStyle.Position] = (Location == MessageBoxLocation.CentreWindow) ? "absolute" : "relative";
WebTable content = new WebTable(3, 1);
WebTable header = CreateTitleBarPanel();
WebTable body = CreateBodyPanel();
WebTable buttons = CreateButtonsPanel();
WebTable footer = CreateFooterPanel();
table[0, 0].Controls.Add(header);
content[0, 0].Controls.Add(body);
content.Width = new Unit(100, UnitType.Percentage);
content[1, 0].HorizontalAlign = HorizontalAlign.Center;
if (DesignMode && Buttons.Count == 0)
{
content[1, 0].Controls.Add(new LiteralControl("Use the Property Browser to add the Message Box Buttons"));
content[1, 0].Font.Bold = true;
content[1, 0].Font.Name = "Verdana";
content[1, 0].Font.Size = new FontUnit(11, UnitType.Pixel);
}
else
{
content[1, 0].Controls.Add(buttons);
}
content[2, 0].Controls.Add(footer);
table.ID = this.ID;
if (Draggable)
{
header.Attributes["onmousedown"] = "dragStart(event, '" + this.UniqueID + "_" + table.ID + "')";
header.Style[HtmlTextWriterStyle.Cursor] = "move";
}
table.Height = base.Height;
table.Width = base.Width;
table[0, 0].Controls.Add(content);
SetMessageBoxLocation(ref table);
ApplyEmbeddedCssClasses(ref table, ref content, ref header, ref body, ref buttons, ref footer);
foreach (Button button in Buttons)
{
button.Click += new EventHandler(Button_Click);
}
return table;
}
protected override void CreateChildControls()
{
MessageBoxTable = BuildHierarchy();
}
protected override void Render(HtmlTextWriter writer)
{
HtmlLink link = GetEmbeddedStyleSheet();
WebTable table = MessageBoxTable;
base.Controls.Add(link);
base.Controls.Add(table);
link.RenderControl(writer);
table.RenderControl(writer);
}
-- modified at 3:31 Monday 10th July, 2006
|
|
|
|
|
Hi there,
Below is a custom MessageBox control which demontrates 3 things in a composite control:
+ Override the CreateChildControls method to add the child controls to the control hierarchy.
+ Override the Render method to control the appearance of the custom control at both design and runtime.
+ Override the OnBubbleEvent method to capture the button command event, and raise the custom Click event of the MessageBox control.
[DefaultProperty("Text")]
[DefaultEvent("Click")]
[ToolboxData("<{0}:MessageBox runat=server></{0}:MessageBox>")]
public class MessageBox : WebControl, INamingContainer
{
private MessageBoxType m_MessageBoxType = MessageBoxType.YesNoCancel;
private Button m_Button1 , m_Button2, m_Button3;
[Category("Action"), Description("Fired when a message button is clicked")]
public event MessageBoxEventHandler Click;
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("Message")]
[Localizable(true)]
public string Text
{
get
{
String s = (String)ViewState["Text"];
return ((s == null) ? "Message" : s);
}
set
{
ViewState["Text"] = value;
}
}
public override ControlCollection Controls
{
get
{
EnsureChildControls();
return base.Controls;
}
}
protected void OnClick(object sender, MessageBoxEventArgs e)
{
if (this.Click != null)
{
this.Click(this, e);
}
}
[DefaultValue(MessageBoxType.YesNoCancel)]
public MessageBoxType MessageBoxType
{
get { return m_MessageBoxType; }
set
{
m_MessageBoxType = value;
EnsureChildControls();
if (m_MessageBoxType == MessageBoxType.AbortRetryIgnore)
BuildMessageBoxButtons("Abort", "Retry", "Ignore", true, true, true);
else if(m_MessageBoxType == MessageBoxType.OkCancel)
BuildMessageBoxButtons("Ok", "Cancel", string.Empty, true, true, false);
else
BuildMessageBoxButtons("Yes", "No", "Cancel", true, true, true);
}
}
private void BuildMessageBoxButtons(string button1Text, string button2Text, string button3Text, bool button1Visible, bool button2Visible, bool button3Visible)
{
m_Button1.Text = button1Text;
m_Button1.Visible = button1Visible;
m_Button1.CommandArgument = button1Text;
m_Button2.Text = button2Text;
m_Button2.Visible = button2Visible;
m_Button2.CommandArgument = button2Text;
m_Button3.Text = button3Text;
m_Button3.Visible = button3Visible;
m_Button3.CommandArgument = button3Text;
}
protected override void CreateChildControls()
{
Controls.Clear();
m_Button1 = new Button();
m_Button1.ID = "Button1";
m_Button2 = new Button();
m_Button2.ID = "Button2";
m_Button3 = new Button();
m_Button3.ID = "Button3";
BuildMessageBoxButtons("Yes", "No", "Cancel", true, true, true);
this.Controls.Add(m_Button1);
this.Controls.Add(m_Button2);
this.Controls.Add(m_Button3);
}
protected override void Render(HtmlTextWriter writer)
{
EnsureChildControls();
writer.Write(Text);
writer.Write("<br/>");
m_Button1.RenderControl(writer);
m_Button2.RenderControl(writer);
m_Button3.RenderControl(writer);
}
protected override bool OnBubbleEvent(object source, EventArgs e)
{
if (e is CommandEventArgs)
{
CommandEventArgs e1 = (CommandEventArgs)e;
MessageBoxResult result = (MessageBoxResult)Enum.Parse(typeof(MessageBoxResult), e1.CommandArgument.ToString());
OnClick(this, new MessageBoxEventArgs(result));
return false;
}
return true;
}
}
public delegate void MessageBoxEventHandler(object sender, MessageBoxEventArgs e);
public class MessageBoxEventArgs : EventArgs
{
private MessageBoxResult m_MessageBoxResult;
public MessageBoxEventArgs(MessageBoxResult result)
{
m_MessageBoxResult = result;
}
public MessageBoxResult MessageBoxResult
{
get { return m_MessageBoxResult; }
}
}
public enum MessageBoxType
{
YesNoCancel,
AbortRetryIgnore,
OkCancel
}
public enum MessageBoxResult
{
None,
Yes,
No,
Cancel,
Abort,
Retry,
Ignore,
Ok
}
|
|
|
|
|