TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kalaivani Kalai
NA
10
438
array out of bounds exception in custom web server control.
Jan 28 2018 11:23 AM
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace SPLITTEXTCONTROL
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:splittext runat=server></{0}:splittext>")]
public class splittext : WebControl
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
private TextBox _firstnametext = new TextBox();
private TextBox _lastnametext = new TextBox();
public string Text
{
get
{
String Text = _firstnametext.Text + _lastnametext.Text;
return ((Text == null) ? "[" + this.ID + "]" : Text);
}
set
{
ViewState["Text"] = value;
}
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_firstnametext.MaxLength = 10;
_lastnametext.MaxLength = 10;
_firstnametext.Width = new Unit("40px");
_lastnametext.Width = new Unit("40px");
}
protected override void RenderContents(HtmlTextWriter output)
{
String str = this.Text;
char[] delimiters = new char[] { ' ', ',' };
string[] parts = str.Split(delimiters);
_firstnametext.Text = parts[0];
_lastnametext.Text = parts[1];
_firstnametext.RenderControl(output);
_lastnametext.RenderControl(output);
}
}
}
what is wrong with my code when i try to create a web server control that parses the seperator for firstname and lastname.please give me a solution to solve this
Reply
Answers (
1
)
How Can i use Regex.Replace with Non-English "ARABIC Strings
Iterating through an array using ForEach