CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: Date Entered: 3/6/2004 2:35:50 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 31 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
"winnieman" <>
NewsGroup User
viewstate on adiv3/6/2004 2:35:50 PM

0

Hi,
I'm trying to use a div as a texteditor. So I want to maintain state in the div using viewstate, but can't get it to work.

protected override void Render(HtmlTextWriter writer)
{
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
writer.AddAttribute("contentEditable", "true");
writer.AddAttribute(HtmlTextWriterAttribute.Width, this.Width.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Height, this.Height.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(this.Text);
writer.RenderEndTag();
}

Can somebody help me with this. I really don't know what I'm doing wrong.
The same code works fine if i change the div in a textbox.

Thx
"joteke" <>
NewsGroup User
Re: viewstate on adiv3/6/2004 5:34:33 PM

0

Hi,

where does the div post/save its text value to/at server? (It doesn't do that by default)

That would happen at client probably to hidden input field which is then posted and assigned to the Text property of the custom div. TextBox posts its text value automatically (and associates it to its Text property) and therefore works. You haven't shown the complete code you have. Post it and we can help you then.
Thanks,

Teemu Keiski
Finland, EU
"master4eva" <>
NewsGroup User
Re: viewstate on adiv3/7/2004 6:36:52 AM

0

It is not an issue of view state -- it is an issue of forms and post back. You might want to have a dig at this source code:

http://www.freetextbox.com/

As Teemu was trying to imply, you have to have a form element as the "medium" of the data being posted back. I would use a hidden field, IMHO. But have a look at FTB and see what tricks John uses.
-- Justin Lovell
"winnieman" <>
NewsGroup User
Re: viewstate on adiv3/7/2004 8:44:54 AM

0

************* Edited by moderator Adec ***************
Inserted missing < code></ code> tags. Always include such
tags when including code in your postings. Many readers
disregard postings without the code tags.
**************************************************

this is the source code
	

[DefaultProperty("Text"),
ToolboxData("<{0}:richedit runat=server></{0}:richedit>")]
public class richedit : System.Web.UI.WebControls.WebControl, System.Web.UI.IPostBackDataHandler
{

private static readonly object EventTextChanged = new object();

[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
string s = (string)ViewState["Text"];
return (s==null) ? String.Empty : s;
}

set
{
ViewState["Text"] = value;
}
}

[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string HtmlTextAreaID
{
get
{
return this.ClientID + "_HtmlTextArea";
}
}

[Category("Action"), Description("Raised when the text in the htmlarea is changed")]
public event EventHandler TexChanged
{
add
{
Events.AddHandler(EventTextChanged, value);
}
remove
{
Events.RemoveHandler(EventTextChanged, value);
}
}


protected override void Render(HtmlTextWriter writer)
{
// TODO: Add richedit.Render implementation
if(Page != null)
Page.VerifyRenderingInServerForm(this);

writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.RenderEndTag(); //td
writer.RenderEndTag(); //tr
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
writer.AddAttribute(HtmlTextWriterAttribute.Value, String.Empty);
writer.AddAttribute("contentEditable", "true");
writer.AddStyleAttribute("padding", "5px");
writer.AddStyleAttribute("OVERFLOW-X", "auto");
writer.AddStyleAttribute("OVERFLOW-Y", "auto");
writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "white");
writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "inset");
writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "2px");
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, this.Width.ToString());
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.Write(this.Text);
writer.RenderEndTag(); //div
writer.RenderEndTag(); //td
writer.RenderEndTag(); //tr
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write("&nbsp;");
writer.RenderEndTag(); //td
writer.RenderEndTag(); //tr
writer.RenderEndTag(); //table


}

protected virtual void OnTextChanged(EventArgs e)
{
EventHandler textChangedHandler = (EventHandler)Events[EventTextChanged];
if(textChangedHandler != null)
{
textChangedHandler(this,e);
}
}

#region IPostBackDataHandler Members

public void RaisePostDataChangedEvent()
{
// TODO: Add richedit.RaisePostDataChangedEvent implementation
OnTextChanged(EventArgs.Empty);
}

public bool LoadPostData(string postDataKey, System.Collections.Specialized.NameValueCollection postCollection)
{
// TODO: Add richedit.LoadPostData implementation
string presentValue = Text;
string postedValue = postCollection[postDataKey];


if(!presentValue.Equals(postedValue))
{
Text = postedValue;
return true;
}
return false;
}

#endregion

}
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:













how do i debug a server control?

custom control and visual studio design support

property lists

adding user properties

composite control designer question

control in user control not instantiated

seperatortemplate

accessing properties of a dynamically added user control

building custom controls

need free web host - suggestions please

building and retrieving dynamic control values

webcontrols

customizing tagprefix !! any idea ???

values to variables from custom control?

dropdown list value

handling <% %> code blocks in customer server controls

which is the best asp.net hosting service around? - site with a million users at a time

html view offers properties editor. what attributes are used with it?

custom control caching...

adding controls in response to postbacks

company wants to see the al of another company we host in their outlook c2003 client

accessing session from within a web control

looking for reliable hosting service. suggestions please.

problem in timer function

controlaction in customcontrol

objects methods

composite control

where to store page-related data?

should a pure windows hosting company offer unix based technology also?

how to reload a page(webform1.aspx) on click of a button in .ascx page

access custom template properties through web form?

id converted to unique id

html analyzer

user control / popup

web custom control: collection editor does not persist values

gridview and dynamic rows...

vsnet ate my code!

removing node from dynamically created tree

databinding usercontrols

why to have both persistchildren and parsechildren attributes?

adding specific controls to a collection to look them up later.

treeview does not callback in netscape 7.2?

creation of dynamic controls during runtime?

my dlls in visual studio.net

counters for controls

email a html page from a given url ?

web stats software

custom control: system.invalidoperationexception error

help with server control terminology

custom web control data binding (non-string properties)

   
  Privacy | Contact Us
All Times Are GMT