To add a confirm box to ur code, try this.
Button1.Attributes.Add("OnClick", "return confirm('Are you Sure you want to
delete this?');");
you can get the message box dialog result like this.
set the CommandArgument Property to some text and check the text in the
button click event.
If the text matches the user has clicked "OK", else cancel.
Ex:
Button1.CommandArgument = "YES";
private void Button1_Click(object sender, System.EventArgs e)
{
//returns "YES" when OK is clicked in the confirm window.
string str1 = ((Button)sender).CommandArgument;
if (str1 == "YES")
{
//add code to do task
}
else
{
//do someother task
}
}
TechStuff - Creativity
Dreams - Thoughts
A wanderous mind, searching something, what is it, thats the peak of inner self, trying to conciously seek the inner being.... haahhah but sways here nd there like a mad man!.....
Thats all it takes to wander around!
Tuesday, November 23, 2004
Monday, November 08, 2004
Web Custom Control Loses Nested Property Values......
When writing web custom controls, we might have the use for some nested property values, (Ex: Style property).
These properties tend to lose their values if they are not persisted.
So include the Persistance attribute to the property to describe how the property wil be persisted.
PersistenceMode(PersistenceMode.InnerProperty)
*************************************************
Sample Property:
private Style cc;
[Bindable(true),
Category("Appearance"),
DefaultValue(""),
PersistenceMode(PersistenceMode.InnerProperty)
]
public Style myColor
{
get
{
return cc;
}
set
{
cc = value;
}
}
This persists the property values as nested tags inside the Control's tag.
MSDN Link - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuipersistencemodeclasstopic.asp
These properties tend to lose their values if they are not persisted.
So include the Persistance attribute to the property to describe how the property wil be persisted.
PersistenceMode(PersistenceMode.InnerProperty)
*************************************************
Sample Property:
private Style cc;
[Bindable(true),
Category("Appearance"),
DefaultValue(""),
PersistenceMode(PersistenceMode.InnerProperty)
]
public Style myColor
{
get
{
return cc;
}
set
{
cc = value;
}
}
This persists the property values as nested tags inside the Control's tag.
MSDN Link - http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuipersistencemodeclasstopic.asp
Thursday, November 04, 2004
Changing the XML Encoding Format when using Selialization
this was a post in a forum and the replynis also included - reply by Jon skeet [MVP].
********
how do you set the encoding format of an XML string? When Iwas outputting the XML to a file you can specify the encoding format likeso:
Post Question:
===========
XmlTextWriter myWriter;
myWriter = new XmlTextWriter(myXMLFile, System.Text.Encoding.UTF8);
XmlSerializer serializer = new XmlSerializer(typeof(@event));
serializer.Serialize(myWriter, myEvent);
but I now want to output the XML as a string:
XmlSerializer serialiser = new XmlSerializer(typeof(@event));
TextWriter textWriter = new StringWriter();
XmlWriter writer = new XmlTextWriter(textWriter);
serialiser.Serialize(writer, myEvent);
strData = textWriter.ToString();
there is no way of setting the encoding format and it is set to UTF16 instead of UTF8 as required by the customer?
Reply:
=====
Use something like this:
public class StringWriterWithEncoding : StringWriter
{
Encoding encoding;
public StringWriterWithEncoding (Encoding encoding)
{
this.encoding = encoding;
}
public override Encoding Encoding
{
get
{
return encoding;
}
}
}
********
how do you set the encoding format of an XML string? When Iwas outputting the XML to a file you can specify the encoding format likeso:
Post Question:
===========
XmlTextWriter myWriter;
myWriter = new XmlTextWriter(myXMLFile, System.Text.Encoding.UTF8);
XmlSerializer serializer = new XmlSerializer(typeof(@event));
serializer.Serialize(myWriter, myEvent);
but I now want to output the XML as a string:
XmlSerializer serialiser = new XmlSerializer(typeof(@event));
TextWriter textWriter = new StringWriter();
XmlWriter writer = new XmlTextWriter(textWriter);
serialiser.Serialize(writer, myEvent);
strData = textWriter.ToString();
there is no way of setting the encoding format and it is set to UTF16 instead of UTF8 as required by the customer?
Reply:
=====
Use something like this:
public class StringWriterWithEncoding : StringWriter
{
Encoding encoding;
public StringWriterWithEncoding (Encoding encoding)
{
this.encoding = encoding;
}
public override Encoding Encoding
{
get
{
return encoding;
}
}
}
SP to get DataType Length in SQL
How do I get the Data Type length for a column in SQL table, might be a simple question, the answer is also pretty simple.
The sp_gettypestring stored procedure returns the type string for the given table id and column id.
Syntax
sp_gettypestring tabid, colid, typestring
where
tabid - is the table id. tabid is int.
colid - is the column id. colid is int.
typestring - is the type string.
It's output parameter. typestring is nvarchar(255).
This is the example to get the type string for the column number 2 in the authors table, from the pubs database.
USE pubs
GO
declare @tabid int, @typestring nvarchar(255)
select @tabid = object_id('authors')
EXEC sp_gettypestring @tabid, 2, @typestring output
select @typestring
GO
Here is the result set from my machine:
-------------------------------
varchar(40)
Link for further reading - http://www.mssqlcity.com/Articles/Undoc/SQL2000UndocSP.htm
The sp_gettypestring stored procedure returns the type string for the given table id and column id.
Syntax
sp_gettypestring tabid, colid, typestring
where
tabid - is the table id. tabid is int.
colid - is the column id. colid is int.
typestring - is the type string.
It's output parameter. typestring is nvarchar(255).
This is the example to get the type string for the column number 2 in the authors table, from the pubs database.
USE pubs
GO
declare @tabid int, @typestring nvarchar(255)
select @tabid = object_id('authors')
EXEC sp_gettypestring @tabid, 2, @typestring output
select @typestring
GO
Here is the result set from my machine:
-------------------------------
varchar(40)
Link for further reading - http://www.mssqlcity.com/Articles/Undoc/SQL2000UndocSP.htm