dsStyle as my Dataset
row for my Datarow.
Dataset dsStyle = // already assigned some records then i want it to get those data display to the page. also if you want to put it on the option box you can do that also.
results.Append("All Style");
foreach (DataRow row in dsStyle.Tables[0].Rows)
{
results.Append("" + DB.RowField(row, "CATEGORYCODE").ToString() + "");
}
Search
Monday, March 23, 2009
Wednesday, March 18, 2009
How to remove the last Letter or char in c#
//I have here a sample text
string m_Value = "Testing 1| Testing 2 | Testing 3 |";
//and then i want to remove the last char " |"
string m_NewValue = m_Value.Substring(0, m_Values.Length - 2);
the output will be:
"Testing 1| Testing 2 | Testing 3"
Hope this help..
string m_Value = "Testing 1| Testing 2 | Testing 3 |";
//and then i want to remove the last char " |"
string m_NewValue = m_Value.Substring(0, m_Values.Length - 2);
the output will be:
"Testing 1| Testing 2 | Testing 3"
Hope this help..
How to get the Current IP in c#
string m_currentIP = HttpContext.Current.Request.UserHostAddress;
Hope this help.. :)
Hope this help.. :)
Wednesday, March 11, 2009
Redirection url onclick event using javascript
You'll just need to have an event onclick and pleace the function redirectURL.
function redirectUrl()
{
window.location = "http://ehamak.blogspot.com";
}
Hope this help..:)
function redirectUrl()
{
window.location = "http://ehamak.blogspot.com";
}
Hope this help..:)
How to get the available fonts style on the server in vb.net
Get all available fonts on the server.
Private Sub LoadFonts()
Dim installed_fonts As New InstalledFontCollection
Dim font_families() As FontFamily = installed_fonts.Families()
' Display the font families.
For Each font_family As FontFamily In font_families
' font_family.Name & ", "
ddlFontName.Items.Add(font_family.Name)
Next font_family
End Sub
Hope this help you.
Private Sub LoadFonts()
Dim installed_fonts As New InstalledFontCollection
Dim font_families() As FontFamily = installed_fonts.Families()
' Display the font families.
For Each font_family As FontFamily In font_families
' font_family.Name & ", "
ddlFontName.Items.Add(font_family.Name)
Next font_family
End Sub
Hope this help you.
How to validate textbox to numeric values only vb.net
This will validate inputed value on the textbox is not a numeric and set it to empty textbox.
If Not (IsNumeric(Me.txtY.Text)) Then
Me.txtY.Text = String.Empty
Me.txtY.Focus()
End If
Hope this will help you to validate you textbox control.
If Not (IsNumeric(Me.txtY.Text)) Then
Me.txtY.Text = String.Empty
Me.txtY.Focus()
End If
Hope this will help you to validate you textbox control.
Show message box in vb.net
This is just sample messagebox code using vb.net language. I place this in the onclick button and prompt it during save. the code looks like this one.
Dim rstResult As DialogResult
rstResult = MessageBox.Show("Are you sure want to update?", _
"Business Card", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question)
If rstResult = DialogResult.Yes Then
// do some action here. is the user selected Yes and nothing is no.
End If
Dim rstResult As DialogResult
rstResult = MessageBox.Show("Are you sure want to update?", _
"Business Card", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question)
If rstResult = DialogResult.Yes Then
// do some action here. is the user selected Yes and nothing is no.
End If
How to split in c#
private void SplitNo()
{
// string seperated by colons ';'
string items = "1--->;2--->;3--->;4--->;5--->";
string[] collection = new string[4];
// define which character is seperating fields
collection = items.Split(';');
for (int x = 0; x < collection.Length; x++) { Response.Write(collection[x] + "
");
}
}
-----------------------------------------------------------
Sample Output:
1--->
2--->
3--->
4--->
5--->
{
// string seperated by colons ';'
string items = "1--->;2--->;3--->;4--->;5--->";
string[] collection = new string[4];
// define which character is seperating fields
collection = items.Split(';');
for (int x = 0; x < collection.Length; x++) { Response.Write(collection[x] + "
");
}
}
-----------------------------------------------------------
Sample Output:
1--->
2--->
3--->
4--->
5--->
How to store and retrive cookie in c#
cookie["Name"] = "Kiko Salva"
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
// To retrieve
lblName.Text = "Cookie Created.";
lblName.Text += "New Customer: " + cookie["Name"];
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
// To retrieve
lblName.Text = "Cookie Created.";
lblName.Text += "New Customer: " + cookie["Name"];
How to remove char and leave number in c#
Regex.Replace Method
Within a specified input string, replaces strings that match a regular expression pattern with a specified replacement string.
ex.
// assigning value into the string xvalue.
string xvalue = "199 RemoveText";
// removing character and leave numbers
decimal value = (decimal)Regex.Replace(xvalue, @"[\D]", "");
//As the result:
199
Within a specified input string, replaces strings that match a regular expression pattern with a specified replacement string.
ex.
// assigning value into the string xvalue.
string xvalue = "199 RemoveText";
// removing character and leave numbers
decimal value = (decimal)Regex.Replace(xvalue, @"[\D]", "");
//As the result:
199
How to create a folder and check if exist on the directory in c#
First i need to create a form with 1 textbox, button and a label in my page. I named the textbox as txtFolderName, button btnCheckandCreate and the label as lblMessage so now, I need to put the event in my button on click.. on the onclick eventon the button i need to put the code.
protected void btnCheckandCreate _Click(object sender, EventArgs e)
{
lblMessage.Text = "";
if (!System.IO.Directory.Exists(@"c:\" + txtFolderName.Text.ToUpper() + ""))
{
System.IO.Directory.CreateDirectory(@"c:\" + txtFolderName.Text.ToUpper() + "");
lblMessage.Text = txtFolderName.Text + " Folder successfully created.";
}
else
{
lblMessage.Text = txtFolderName.Text + " is not available";
}
}
protected void btnCheckandCreate _Click(object sender, EventArgs e)
{
lblMessage.Text = "";
if (!System.IO.Directory.Exists(@"c:\" + txtFolderName.Text.ToUpper() + ""))
{
System.IO.Directory.CreateDirectory(@"c:\" + txtFolderName.Text.ToUpper() + "");
lblMessage.Text = txtFolderName.Text + " Folder successfully created.";
}
else
{
lblMessage.Text = txtFolderName.Text + " is not available";
}
}
Subscribe to:
Posts (Atom)