RadhaKrishnaKiJaya
asked on
Open the Phone number on phone pad when the link is clicked
Hi Experts,
I have a link button with a phone number.
<div>
<asp:LinkButton ID="lblMobilePhone" runat="server"></asp:LinkB utton>
</Div>
When I click the link button it should open the phone number on the phone pad. I know how to do it when the link is inside a gridview. But how to do it if it is out side inside a DIV tag.
Thanks.
I have a link button with a phone number.
<div>
<asp:LinkButton ID="lblMobilePhone" runat="server"></asp:LinkB
</Div>
When I click the link button it should open the phone number on the phone pad. I know how to do it when the link is inside a gridview. But how to do it if it is out side inside a DIV tag.
Thanks.
ASKER
Thank you very much for you reply. I do not want static values. I want something like this. But it does not work.
<asp:linkbutton ID="lblMobilePhone" runat="server" href='<%# String.Format("tel:" & lblMobilePhone.Text)%>'></ asp:linkbu tton>
Phone number is coming from the DB. I want the same number to pop up.
Thanks.
<asp:linkbutton ID="lblMobilePhone" runat="server" href='<%# String.Format("tel:" & lblMobilePhone.Text)%>'></
Phone number is coming from the DB. I want the same number to pop up.
Thanks.
<asp:LinkButton runat="server" ID="lb1" PostBackUrl='<%# String.Format("tel:"& lblMobilePhone.Text)%>' Text='<%# lblMobilePhone.Text %>' ></asp:LinkButton>
You have to set both the post back URL and the text url.
Also you should be binding to the source directly, not to some other control.
MVC or Webforms . . . you might be better of just doing this from the code behind when you get the response back from the DB.
You have to set both the post back URL and the text url.
Also you should be binding to the source directly, not to some other control.
MVC or Webforms . . . you might be better of just doing this from the code behind when you get the response back from the DB.
ASKER
Can u please tell me how to do it code behind?
This is my code.
Dim cmd As New SqlCommand
cmd.CommandText = "Select * from CUSTCONTACT where Id=" & ContactID
con.Open()
cmd.Connection = con
Reader = cmd.ExecuteReader()
While Reader.Read
lnkHomePhone.Text = Reader.Item("HomePhone").T oString
End While
con.Close()
Thanks.
This is my code.
Dim cmd As New SqlCommand
cmd.CommandText = "Select * from CUSTCONTACT where Id=" & ContactID
con.Open()
cmd.Connection = con
Reader = cmd.ExecuteReader()
While Reader.Read
lnkHomePhone.Text = Reader.Item("HomePhone").T
End While
con.Close()
Thanks.
I would change your code to following
I am not sure if telephone bit will work but atleast it will be more efficient
I am not sure if telephone bit will work but atleast it will be more efficient
Dim cmd As New SqlCommand
cmd.CommandText = "Select Top 1 HomePhone from CUSTCONTACT where Id=" & ContactID
con.Open()
cmd.Connection = con
Dim Phone as Object = cmd.ExecuteScalar()
If Not IsDBNull(Phone) Then
lnkHomePhone.Text = "tel:" & Phone
End If
con.Close()
ASKER
Thank you for your reply. But it is not working. When I give lnkHomePhone.Text = "tel:" & Phone, It is coming as "tel:219-545-5240" .
Thanks.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does it work if you modify the HomePhone field in DB to contain a valid phone number (starting with 0 or 00, no spaces or dashes etc)?
ASKER
It worked!! Thank you very much for your help.
eg:
<asp:LinkButton runat="server" ID="lb1" PostBackUrl="tel:858555121
you can also control these properties from the code behind.