|
hello everybody
i have a disit or string like.....
9871234567890
i need only last 10 disit or char like
1234567890
how can i do it?
thanks in advance
Sarfarj Ahmed
|
|
|
|
|
dim longString as string = "9870123456789"
dim shortString as string = longString.SubString(3)
You know, you could have probably found out the answer by yourself in less time than it took you to post this!
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
This code is properly working;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userID.ToString(),
DateTime.Now, DateTime.Now.AddMinutes(30), false, userRole.ToString(), FormsAuthentication.FormsCookiePath);
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(userID.ToString(), false));
*****But if I use Try-Catch pattern, catch block is running;
try
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userID.ToString(), DateTime.Now, DateTime.Now.AddMinutes(30), false, userRole.ToString(), FormsAuthentication.FormsCookiePath);
string encTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
cookie.Expires = DateTime.Now.AddYears(1);
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(userID.ToString(), false));
}
catch (Exception ex)
{
Response.Redirect("ErrorPage.aspx");
}
Exception Error Message is;
ex = {Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
Why I get this message? How can I correct it?
Thanks...
|
|
|
|
|
Accually this code solve my problem;
try
{
//My Code
}
catch (System.Threading.ThreadAbortException ex)
{
//ignore error.
}
catch (Exception ex)
{
Response.Redirect("ErrorPage.aspx");
}
But I think this is not a good solution.
Why do I get this message? How can I correct it?
Best Regards...
|
|
|
|
|
From the MSDN documentation for HttpResponse.Redirect:
'Redirect calls End which raises a ThreadAbortException exception upon completion.'
It is part of the implementation of the Redirect method that a ThreadAbortException is raised. You can catch that particular exception and ignore it.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
Please Guys look at my Code,it is working when I click Button1 it lots all the controls that I want inside a repeator,But My problem is that I want the second dropdown inside a repeator to display the value depending/according on the first dropdown selection.How do I go about?
Eg DropDown1 loads all the car name(toyota,audi,bmw)
after selection,maybe (Audi)Dropdown2 load(A3,A4) Who do I go about inside the repeator
Code
Imports System.Net.Mail
Partial Class cap
Inherits System.Web.UI.Page
Dim OSource As Businesslayer.Users = New Businesslayer.Users
Dim rs As Data.DataSet
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As New Data.DataSet
Dim obj As Businesslayer.ClientSite = New Businesslayer.ClientSite
Dim NumberOfBoxes As Integer
Dim WhichBox As Integer
Dim rows() As Integer
NumberOfBoxes = Integer.Parse(txtDay.Text) - 1
ReDim rows(NumberOfBoxes)
For WhichBox = 0 To NumberOfBoxes
rows(WhichBox) = WhichBox
Next
Repeater1.DataSource = rows
Repeater1.DataBind()
For WhichBox = 0 To NumberOfBoxes
Dim cmbProjectName As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectName"), DropDownList)
ds = obj.GetProjectNameFromProjAdmin
cmbProjectName.DataSource = ds
cmbProjectName.DataBind()
cmbProjectName.Items.Add(New ListItem("", ""))
cmbProjectName.Items.Item(cmbProjectName.Items.Count - 1).Selected = True
Dim cmbClientSite As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbClientSite"), DropDownList)
ds = obj.GetClientIDFromProjAdmin
cmbClientSite.DataSource = ds
cmbClientSite.DataBind()
cmbClientSite.Items.Add(New ListItem("", ""))
cmbClientSite.Items.Item(cmbClientSite.Items.Count - 1).Selected = True
Dim cmbProjectManager As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectManager"), DropDownList)
ds = obj.GetProjectManagers
cmbProjectManager.DataSource = ds
cmbProjectManager.DataBind()
cmbProjectManager.Items.Add(New ListItem("", ""))
cmbProjectManager.Items.Item(cmbProjectManager.Items.Count - 1).Selected = True
Dim cmbCategory As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbCategory"), DropDownList)
ds = obj.GetCategory
cmbCategory.DataSource = ds
cmbCategory.DataBind()
cmbCategory.Items.Add(New ListItem("", ""))
cmbCategory.Items.Item(cmbCategory.Items.Count - 1).Selected = True
Next
End Sub
Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
Repeater1.FindControl("DropDownList1")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rptErrors As New ValidationSummary
If Page.IsPostBack = False Then
txtProjectMember.Text = Session("Name") & " " & Session("Surname")
txtIDNumber.Text = Session("IdNumber")
txtEmail.Text = Session("Email")
bntSubMana.Visible = "False"
rptErrors.Visible = False
End If
'If Not Page.IsPostBack Then
' rptErrors.Visible = False
'End If
End Sub
Public Sub UserMsgBox(ByVal sMsg As String)
Dim sb As New StringBuilder
Dim oFormObject As System.Web.UI.Control
sMsg = sMsg.Replace("'", "\'")
sMsg = sMsg.Replace(Chr(34), "\" & Chr(34))
sMsg = sMsg.Replace(vbCrLf, "\n")
sMsg = "alert(""" & sMsg & """)"
sb = New StringBuilder
sb.Append(sMsg)
For Each oFormObject In Me.Controls
If TypeOf oFormObject Is HtmlForm Then
Exit For
End If
Next
Controls.AddAt(Controls.Count, New LiteralControl(sb.ToString()))
End Sub
Protected Sub ButtonSubMana_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bntSubMana.Click
Dim ds1 As New Data.DataSet
Dim obj As Businesslayer.TimeSheet = New Businesslayer.TimeSheet
Dim NumberOfBoxes As Integer
Dim WhichBox As Integer
'Dim WeekN As Date
NumberOfBoxes = Integer.Parse(WhichBox)
Dim rows(NumberOfBoxes) As Integer
'Dim Repeater1 As Repeater
For WhichBox = 0 To NumberOfBoxes
'Dim ImageButton1 As ImageButton
Dim txtWeekNumber As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtWeekNumber"), TextBox)
Dim txtDate As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtDate"), TextBox)
Dim cmbProjectName As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectName"), DropDownList)
Dim cmbClientSite As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbClientSite"), DropDownList)
Dim cmbProjectManager As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectManager"), DropDownList)
Dim cmbProjectMember As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbProjectMember"), DropDownList)
Dim cmbCategory As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbCategory"), DropDownList)
Dim cmbOccupation As DropDownList = CType(Repeater1.Items(WhichBox).FindControl("cmbOccupation"), DropDownList)
Dim txtHours As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtHours"), TextBox)
Dim CheckBox1 As CheckBox = CType(Repeater1.Items(WhichBox).FindControl("CheckBox1"), CheckBox)
Dim txtDescription As TextBox = CType(Repeater1.Items(WhichBox).FindControl("txtDescription"), TextBox)
Dim errors As ArrayList = New ArrayList
Dim rptErrors As New ValidationSummary
If txtDate.Text = "" Then
errors.Add(New validation("Please Enter your Date"))
End If
If cmbProjectName.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A ProjectName"))
End If
If cmbClientSite.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A ClientSite"))
End If
If cmbProjectManager.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A ProjectManager"))
End If
If cmbCategory.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A Category"))
End If
If cmbOccupation.SelectedItem.Text = "" Then
errors.Add(New validation("Please select A Occupation"))
End If
If txtHours.Text = "" Then
errors.Add(New validation("Please Enter your Hours"))
End If
If txtDescription.Text = "" Then
errors.Add(New validation("Please Enter you Job Description"))
End If
If errors.Count > 0 Then
'rptErrors.DataSource = errors
rptErrors.DataBind()
rptErrors.Visible = True
Else
End If
obj.addTimesheet(Session("Id"), cmbProjectName.SelectedValue, cmbClientSite.SelectedValue, cmbProjectManager.SelectedValue, txtDate.Text, txtWeekNumber.Text, Double.Parse(txtHours.Text), CheckBox1.Checked, cmbCategory.SelectedItem.Value, Session("Userid"), txtDescription.Text, "2")
cmbProjectName.Text = ""
cmbClientSite.Text = ""
cmbProjectManager.Text = ""
cmbCategory.Text = ""
txtDate.Text = ""
txtWeekNumber.Text = ""
txtDescription.Text = ""
txtHours.Text = ""
cmbCategory.Text = ""
Next
'Dim NumberOfEmails As Integer
'Dim NoRows As Integer
'Dim ArrayEmail(20)() As Array
Dim i As Integer
Dim EmailInfo As New Data.DataSet
Dim table As Data.DataTable
Dim row As Data.DataRow
'Dim column As Data.DataColumn
' For each table in the DataSet, print the row values.
For i = 0 To Repeater1.Items.Count - 1
Dim txtWeekNumber As TextBox = CType(Repeater1.Items(i).FindControl("txtWeekNumber"), TextBox)
Dim txtDate As TextBox = CType(Repeater1.Items(i).FindControl("txtDate"), TextBox)
Dim cmbProjectName As DropDownList = CType(Repeater1.Items(i).FindControl("cmbProjectName"), DropDownList)
Dim cmbClientSite As DropDownList = CType(Repeater1.Items(i).FindControl("cmbClientSite"), DropDownList)
Dim cmbProjectManager As DropDownList = CType(Repeater1.Items(i).FindControl("cmbProjectManager"), DropDownList)
Dim cmbProjectMember As DropDownList = CType(Repeater1.Items(i).FindControl("cmbProjectMember"), DropDownList)
Dim cmbCategory As DropDownList = CType(Repeater1.Items(i).FindControl("cmbCategory"), DropDownList)
Dim cmbOccupation As DropDownList = CType(Repeater1.Items(i).FindControl("cmbOccupation"), DropDownList)
Dim txtHours As TextBox = CType(Repeater1.Items(i).FindControl("txtHours"), TextBox)
Dim CheckBox1 As CheckBox = CType(Repeater1.Items(i).FindControl("CheckBox1"), CheckBox)
Dim txtDescription As TextBox = CType(Repeater1.Items(i).FindControl("txtDescription"), TextBox)
Dim EmailMessage As String
For Each table In EmailInfo.Tables
For Each row In table.Rows
' Response.Write(row(0) + " " + row(1))
Dim from As MailAddress = New MailAddress("timesheet@ecominstitute.com", Session("Name") & " " & Session("Surname"))
Dim recieve As MailAddress = New MailAddress(row(0), row(1))
EmailMessage = " Dear " & row(1) & "
" & _
"This is to notify that the TimeSheet for this week is as follows :
" & _
" " & _
"Date | Project Name | Client Site | Hour | Description | " & txtDate.Text & " | " & cmbProjectName.SelectedItem.Text & " | " & cmbClientSite.SelectedItem.Text & " | " & txtHours.Text & " | " & txtDescription.Text & " | "
Dim message As MailMessage = New MailMessage(from, recieve)
message.Subject = "Weekly TimeSheets For :" & txtProjectMember.Text
message.IsBodyHtml = True
message.Body = EmailMessage
'Dim copy As MailAddress = New MailAddress("Notification_List@contoso.com")
'message.CC.Add(copy)
Dim client As SmtpClient = New SmtpClient("srjhbex01", 25)
client.Send(message)
Next row
Next table
Next
UserMsgBox("Your Time-Sheet has been to the Manager for Approval")
End Sub
Protected Sub txtDay_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtDay.TextChanged
Dim bntPrint As New Button
If txtDay.Text <= 0 Then
Repeater1.Visible = False
UserMsgBox("Please Enter the Number Greater than 0")
Else
Repeater1.Visible = True
bntSubMana.Visible = "True"
End If
End Sub
End Class
|
|
|
|
|
Hello I have a string variable declared in a Webform
Is there a way in which I can modify the value of that variable with javascript?
can I use something like getElementById, or something that can allow me to get that variable?
thanks
|
|
|
|
|
It's a server side variable (declared in the C# code),the answer is no. You can use for instance a hidden field , and in a postback get that value.
/// -------------------------
Braulio Díez
tipsdotnet.com
/// -------------------------
|
|
|
|
|
Really???
Well, I'll live
thanks man
|
|
|
|
|
I'm exporting a datagrid to excel. I use itemCreated and OreRender to change the rows and put more header rows but when i export the changes don't appear in the excel.
Nzibi
|
|
|
|
|
|
Hi,
I need to work on a requirement that like MaskTextBox that in window.
Actual requirement is I have to diplay the Time in a single text box in HH:MM:SS format with two buttons increment and decrement. It is very similar to DateAndTime Properties window of Windows. It is any possiblites to do that in ASP.NET.
Thanks in Advance
Regards
Prakash.A
Good Is Not Good When Better Is Expected.
|
|
|
|
|
A AntonySP wrote: It is any possiblites to do that in ASP.NET.
ASP.NET can't do anything on this because it works on the server. You may do this using JS. AFAIK, no built-in controls available for such a requirement.
|
|
|
|
|
|
|
I didn't think the quality of posts in this forum could get any worse but today has proved me wrong.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
|
You're quite right. And sonia hasn't even been on today...
|
|
|
|
|
Paddy Boyd wrote: And sonia hasn't even been on today
Does the forum really miss a vibrant activity?
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
|
Hi
In my application data is comming from veb server to my localserver.
For this purpose i'm establishing connection to webdatabase and matching the id(uniqueno) from web database to local database tables. If already exist then no insert if not exist then insert.
In this case the problem is that, suppose there are 1 lakh records on web database then my application will check for 1 lakh time. And i think it's not a right way to do this stuff.
Please suggest me any better solution.
Thanks
krishna veer singh
|
|
|
|
|
krishnaveer wrote: In this case the problem is that, suppose there are 1 lakh records on web database then my application will check for 1 lakh time. And i think it's not a right way to do this stuff.
Sorry bud, but you are not making any sense. What is "1 lakh"? Why don't you write a webservice, and pass a dataset back to your local server (makes it easier to compare). Are you just posting data to your webserver now each time? If so you are right, it is not very efficient.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
my solution file is getting saved in the default location of dotnet which is in Document settings..Can any one please tell me how to save .sln file with the .aspx files
Thanks in advance
|
|
|
|
|
1. You can simply save-as .sln file in new location.
OR
2. There is one option to change the path in Options dialog of VS 2005. but this might not be what you want since the .sln will save in the location that you changed in "options" dialog..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|