|
Ok pa....! Thanks friend....!
|
|
|
|
|
REGISTRATION.ASPX
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class registration : System.Web.UI.Page
{
Class2 obj1 = new Class2();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
obj1.exec("insert into tblregister (name,address,gender,email,fon,uname,pwd)values ('"+TextBox1.Text+"','"+TextBox2.Text+"','"+RadioButtonList1.SelectedItem.Text+"','"+TextBox3.Text+"','"+TextBox4.Text+"','"+TextBox5.Text+"','"+TextBox6.Text+"')");
}
protected void Button3_Click(object sender, EventArgs e)
{
TextBox1.Text = string.Empty;
TextBox2.Text = string.Empty;
TextBox3.Text = string.Empty;
TextBox4.Text = string.Empty;
TextBox5.Text = string.Empty;
TextBox6.Text = string.Empty;
}
public void bind()
{
obj1.getdata("select * from tblregister");
GridView1.DataSource = obj1.dt;
GridView1.DataBind();
}
protected void Button4_Click(object sender, EventArgs e)
{
bind();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
bind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string p = GridView1.DataKeys[e.RowIndex].Value.ToString();
string name = ((TextBox)GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text;
string address = ((TextBox)GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text;
string phone = ((TextBox)GridView1.Rows[e.RowIndex].Cells[6].Controls[0]).Text;
string password = ((TextBox)GridView1.Rows[e.RowIndex].Cells[8].Controls[0]).Text;
obj1.exec("update tblregister set name='" + name + "',address='" + address + "',fon='" + phone + "',pwd='" + password + "' where id='" + p + "' ");
bind();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
bind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string id1 = GridView1.DataKeys[e.RowIndex].Value.ToString();
obj1.exec("delete from tblregister where id= + id1");
bind();
}
}
CLASS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using MySql.Data.MySqlClient;
using System.Configuration;
public class Class1
{
public MySqlConnection con=new MySqlConnection(ConfigurationManager.ConnectionStrings[@"sjober"].ToString());
public MySqlCommand cmd = new MySqlCommand();
public DataTable dt=new DataTable();
public MySqlDataAdapter ad=new MySqlDataAdapter();
string s;
public Class1()
{
}
public MySqlConnection getcon()
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
else
{
con.Open();
}
return con;
}
public DataTable getdata(string cmdtxt)
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = cmdtxt;
ad.SelectCommand = cmd;
ad.Fill(dt);
return dt;
}
public string exec(string cmdtxt)
{
try
{
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = cmdtxt;
cmd.Connection = getcon();
s = cmd.ExecuteNonQuery().ToString();
cmd.Connection = getcon();
}
catch (Exception ex)
{
ex.ToString();
}
return s;
}
}
<div class="signature">JINSON JOHN</div>
|
|
|
|
|
|
Your code is vulnerable to SQL Injection[^].
NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Too late, your bank is already using his code.
|
|
|
|
|
Hi All,
I have payment gateway PAYUMONEY.I am trying to integrate the code in my project.The code in my project will attached to master page.
When i integrate the code and run i am getting the error:
https://test.payu.in/_payment
Error. We are sorry we are unable to process your payment.
Checksum Failed. Please contact your merchant.
I provided all the mandatory fields.It is working fine in webform(.aspx) page but when i attach this page to master page i am getting this error.
Could anybody please suggest for this error.
Thanks
Murali
|
|
|
|
|
We can't help at all if we can't see what you have done. You should edit your question and post the relevant code.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Yes you need to have a reference in web.config
Thanks
Murali
|
|
|
|
|
Hello
Thanks for your reply.
I am trying to use the correct code to reference sitemap in Web.config, but my browser gives me errors if I use:
<siteMap defaultProvider="siteMap">
<siteMap defaultProvider="siteMap.xml">
<siteMap defaultProvider="siteMap.xml" enabled="true" >
<siteMap defaultProvider="siteMap" enabled="true" >
My sitemap is called sitemap and is an xml file that looks like this:
<?xml version="1.0"?>
<siteMap>
<siteMapNode title="Home" description="Home" url="~/index.aspx" />
<siteMapNode title="Register" description="Register" url="~/Register.aspx" />
<siteMapNode title="Login" description="Login" url="~/Login.aspx" />
<siteMapNode title="Upload" description="Upload your files" url="~/upload.aspx" />
<siteMapNode title="My Work" description="My Work" url="~/mywork.aspx" />
<siteMapNode title="Contact me" description="Contact me" url="~/Contact.aspx" />
<siteMapNode title="Error" description="Website error" url="~/error.aspx" />
</siteMap>
I have checked with an online validator and the code has no errors.
My Web.config looks like this:
<siteMap defaultProvider="siteMap" enabled="true" >
<!--<siteMap defaultProvider="XmlSiteMapProvider">-->
<!--<siteMap defaultProvider="siteMap.xml">-->
<providers>
<!--<add name="SimpleTextSiteMapProvider" type="Samples.AspNet.SimpleTextSiteMapProvider,Samples.AspNet" siteMapFile="siteMap.xml"/>-->
<add name="SimpleTextSiteMapProvider" type="XmlSiteMapProvider" siteMapFile="siteMap.xml"/>
</providers>
</siteMap>
</system.web>
As you can see, I have tried a few possibilies but still not getting anywhere!
Thanks again for reply.
|
|
|
|
|
how can i create dynamic checkbox and get that's value when i click button
in asp.net using vb.net
modified 6-Dec-14 13:55pm.
|
|
|
|
|
Please don't double-post.
|
|
|
|
|
Hi All,
I have a master page attached to a webform .
I have 2 UserControl in the webform
When i click on the submit button the controls are dissappearing.
How can we make the usercontrol visible always.
Please share your views and answers.
Thank You
B Mehar Murali
|
|
|
|
|
How did you add your user Control .
its better you can add your usercontrol to Placeholder control at page load.
for example hope this will helpe you.
private void Page_Load(object sender, EventArgs e)
{
Control cnt = LoadControlYourUsercontrol.ascx");
placeholder.Controls.Add(yourusercontrol)
}
|
|
|
|
|
Page_Init is the better place to dynamically add Controls because it is highly probable that it will persists values after post-back if you add dynamic controls at Page_Init.
Microsoft also recommends it.
Life is a computer program and everyone is the programmer of his own life.
|
|
|
|
|
Yes I accept. Its good to declare in page Init
|
|
|
|
|
Thanks Syed and Anurag,
I resolved the issue .Thanks for the advice.
|
|
|
|
|
This line of code:
<p id="results"></p>
displays the total miles when calculated between two locations using the javascript code below:
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7j_Q-rshuWkc8HyFI4V2HxQYPm-xtd00hTQOC0OXpAMO40FHAxT29dNBGfxqMPq5zwdeiDSHEPL89A" type="text/javascript"></script>
<!--
<script type="text/javascript">
var geocoder, location1, location2;
function initialize() {
geocoder = new GClientGeocoder();
}
function showLocation() {
geocoder.getLocations(document.forms[0].address1.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the first address");
}
else
{
location1 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
geocoder.getLocations(document.forms[0].address2.value, function (response) {
if (!response || response.Status.code != 200)
{
alert("Sorry, we were unable to geocode the second address");
}
else
{
location2 = {lat: response.Placemark[0].Point.coordinates[1], lon: response.Placemark[0].Point.coordinates[0], address: response.Placemark[0].address};
calculateDistance();
}
});
}
});
}
function calculateDistance()
{
try
{
var glatlng1 = new GLatLng(location1.lat, location1.lon);
var glatlng2 = new GLatLng(location2.lat, location2.lon);
var miledistance = glatlng1.distanceFrom(glatlng2, 3959).toFixed(1);
document.getElementById('results').innerHTML = 'Address 1: ' + location1.address + '<br />Address 2: ' + location2.address + '<br />Distance: ' + miledistance + ' miles (or ' + kmdistance + ' kilometers)';
}
catch (error)
{
alert(error);
}
}
</script>
</head>
<body onload="initialize()">
<form action="#" onsubmit="showLocation(); return false;">
<p>
<input type="text" name="address1" value="Address 1" class="address_input" size="40" />
<input type="text" name="address2" value="Address 2" class="address_input" size="40" />
<input type="submit" name="find" value="Search" />
</p>
</form>
<p id="results"></p>
</body>
</html>
I am using ASP.NET to build an app and would like to use some sort of hidden variable to store value of
<p id="results"></p>
and set it at server side to the corresponding control but I am having difficulty thinking up how to do this.
Can someone please assist with this?
I would really appreciate it.
|
|
|
|
|
You can use an asp:Label and set it's value server side.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I tried that already and it didn't work.
|
|
|
|
|
What didn't work?
And what are you trying to do then?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I understand what you are trying to do, but not really sure what you are asking... javascript code runs on the client side, the values set on #results are added after the client has loaded the javascript and calculated the distance. Are you attempting to send this data back to the server?
you can always use a hidden input
<input type="hidden" value="something" name="result" />
or:
<asp:HiddenField runat="server" ID="result" />
which can then be ran on postback and checked for a value.
|
|
|
|
|
You have to put that in a hidden textbox.
The asp.net server remembers everything it generates, and sends back to the browser. So take a dropdownbox for instance, if you populate a dropdown box, and then use javascript to clear it, the server will think that someone tampered with the value, and generate an error. But with a textbox, the server expects the values to change, so that's OK.
Only HTML Elements with the word input really post back to the server. All others don't, it's a waste of time and bandwidth.
button
checkbox
color
date
datetime
datetime-local
email
file
hidden
image
month
number
password
radio
range
reset
search
submit
tel
text
time
url
week
So a textbox and a dropdown box use the input element, which is programmable to act like a textbox, dropdownlist, radio button, checkbox and so forth.
Make a asp.net textbox object, and set the CSS display: none
style="display: none;"
Were using the CSS style because I'm skeptical of the visible attribute.
Let the textbox show until you prove it works, then use the display.
Were using clientIDmode, because the id value will stay the same for use in javascript.
Off the top of my head;
<asp:textbox id="txt_geolocation" runat="server" <b="">clientIDmode="static" style=display: none;">
If you don't make the asp.net object, the textbox will most likely give you trouble posting back it's value.
[edit]
document.getElementById('txt_geolocation').value('stuff you geolocation info in here');
textbox use the attr value, and has no innerHTML.
|
|
|
|
|
Thank you guys, all of you for your kindness with your responses.
Ryan, I should have been more much clearer. When I said it doesn't work, I meant that yes, it will display results in labels but I could not pass the value of the results to codebehind.
Second, I can't pass that value from one multiview to another.
Here are some examples:
<asp:MultiView ID="myMultiView" ActiveViewIndex="0" runat="server">
<asp:View ID="vwPersonalData" runat="server">
<p>
<asp:TextBox ID="address1" runat="server" Text="Marietta, GA" ClientIDMode="Static"></asp:TextBox>
<asp:TextBox ID="address2" runat="server" Text="Birmingham, AL" ClientIDMode="Static"></asp:TextBox>
</p>
<%----%>
<asp:Label ID="results" runat="server" Text="" Style="display: none" ClientIDMode="Static"></asp:Label>
<asp:HiddenField runat="server" ID="result" />
</asp:View>
<asp:View ID="vwPreview" runat="server">
<br />
<!--
<span style="font-weight:bold;font-size:medium;">Please verify your order:</span><span style="color:Red;font-weight:bold;"> 10% discount applied</span>
<br /> <br />
<table>
<tr>
<td>Estimated Total Miles:</td>
<td><asp:Label ID="lblMiles" runat="server" /></td>
</tr>
<table>
</asp:View>
</asp:MultiView>
<asp:Button ID="btnBack" runat="server" Text="< Back " OnClick="btnBack_Click" />
<asp:Button ID="btnNext" runat="server" Text="Next >" OnClientClick="showLocation();" OnClick="btnNext_Click" />
<asp:Button ID="btnSend" runat="server" Text="Send request" OnClick="btnSend_Click" />
</form>
//codebehind
Dim Hiddenresult As HiddenField = form1.FindControl("result")
lblMiles.Text = Hiddenresult.Value
As you can see from the sample codes, I am trying to get the value of Hidden field called results and pass that value to preview multiview page called vwPreview but it always comes up blank.
What am I doing wrong?
|
|
|
|
|
Don't put the hidden textbox inside the multi view control, place it on the page at the bottom.
when you make the textbox, get the value "" or string.empty
To diagnose, you have to follow the steps.
Step 1: Does the data appear in the textbox
Use a regular textbox, and keep it visible, so you can see the data appear in it from your Javascript. Confirm that you can write to the textbox.
Diagnose: Try using IE11, press F12, click on the bug, 3rd down on left, and it will tell you if you have a script error, preventing the write.
Step2: Post the form back to the server.
On the Button Click event, look for the textbox value being posted back.
Diagnose: If the textbox has data in it, but no data came back to the server,
Check your use of
Page.IsPostback
button_click
if page.ispostback then
look for the textbox text.
end if
I don't know what a multiview control is, so no help from me there on that subject. Fix 1 thing at a time in sequence.
Oh, I'm jkirkerx, not RyanDev.
|
|
|
|
|