|
OK but i said that what problem is.
I have three page.
The default page and one user control and third ,code behind of the user control that i have put it in previous post.
My program work correctly without the ScriptManagerProxy (without Ajax) but with it doesn't work.(in the .ascx page).
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
</asp:ScriptManagerProxy>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<%--------my code--------%>
</ContentTemplate>
</asp:UpdatePanel>
If i remove the Ajax tag that have put above,my program hasn't any problem BUT if put it ,doesn't work properly.
now do you help me?
modified 2-Jan-14 5:59am.
|
|
|
|
|
Sorry, I'm not an ASP expert. I was merely suggesting that you need to provide full details of your problem if you want people to help you. Don't assume that people can guess what you are doing.
Veni, vidi, abiit domum
|
|
|
|
|
hello again
see,my problem exactly is that my program without putting the ScriptManagerProxy hasn't any problem and works properly.but with it doesn't work.
"doesn't work" is in other word,not that my program has an error,no,only works bad.(i haven't a syntax error while have a runtime error only and only for the ScriptManagerProxy tag )
for more explanations:
in the code below,if we haven't ScriptManagerProxy tag in the page,we can to enter the values in the fiels and press the button to sends the values.but if we put ScriptManagerProxy tag in the page,the program isn't able to send the values because says FileUpload1.HasFile is false (fileupload1 is empty)then the if condition isn't true therefore my Query doesn't run.i hope to explain properly.
<table class="style1">
<tr>
<td>
<asp:Label ID="Label2" runat="server" Text="ای دی دسته بندی محصول"></asp:Label>
</td>
<td>
<asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"
DataSourceID="SqlDataSource1" DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="نام محصول"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtProName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtProName" Display="Dynamic"
ErrorMessage="نام محصول را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="قیمت"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtCast" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="txtCast" Display="Dynamic"
ErrorMessage="قیمت را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="عکس یا فیلم"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label6" runat="server" Text="توضیحات"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
ControlToValidate="txtComment" Display="Dynamic"
ErrorMessage="توضیحات را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label7" runat="server" Text="موجودی"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtStock" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txtStock" Display="Dynamic"
ErrorMessage="موجودی را وارد نکرده اید" SetFocusOnError="True">*</asp:RequiredFieldValidator>
</td>
</tr>
</table>
<br />
<!---------------------->
<!------------------------------------------------------------------------>
<asp:Button ID="btnAddProductions" runat="server" Text="add productions" onclick="btnAddProductions_Click" />
<!------------------------------------------------------------------------>
<asp:Label ID="lblResult" runat="server" ForeColor="Red"></asp:Label>
<br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
in this code behind file in below,the running of the query is dependent to correctness fileOK variable.
therefore first must FileUpload1.HasFile be true.
when the program runs,and i fill the fields and press the button,the program jumps on "else" and runs
lblResult.Text="the format of the image isn't true";
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.IO;
public partial class Admin_Productions : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAddProductions_Click(object sender, EventArgs e)
{
bool fileOK = false;
string[] allow = { ".jpg", ".jpeg", ".gif", ".bmp", ".png" };
string fileExtension = Path.GetExtension(FileUpload1.FileName).ToLower().Trim();
if (FileUpload1.HasFile)
{
for (int i = 0; i < allow.Length; i++)
{
if (fileExtension == allow[i] && FileUpload1.FileBytes.Length < 1048576)
{
fileOK = true;
}
}
}
if (fileOK==true)
{
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/"+FileUpload1.FileName));
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString);
string query = "insert into tbl_production values (@proCatId,@proName,@proCast,@proPic,@proComment,@proStock)";
SqlCommand cm = new SqlCommand(query, cn);
cm.Parameters.AddWithValue("proCatId", DropDownList2.SelectedValue);
cm.Parameters.AddWithValue("proName", txtProName.Text.Trim().ToLower());
cm.Parameters.AddWithValue("proCast", txtCast.Text.Trim());
cm.Parameters.AddWithValue("proPic", "~/images/"+FileUpload1.FileName.Trim().ToLower());
cm.Parameters.AddWithValue("proComment", txtComment.Text);
cm.Parameters.AddWithValue("proStock", txtStock.Text);
cn.Open();
cm.ExecuteNonQuery();
lblResult.Text = "the new production is registered";
cn.Close();
}
else
{
lblResult.Text = "the format of the image isn't true";
}
}
}
modified 2-Jan-14 8:22am.
|
|
|
|
|
How to find curses movement in text box
Suppose i have written like 45hgy
now by command button i want to insert betwenn 45h and gy
like 45hanygy
How
Thanks
|
|
|
|
|
Where are you stuck?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
hello.. i'm having a problem while binding the values to drop down chosen i'm not getting a search box to enter the text for auto search..please, kindly reply as soon as possible
|
|
|
|
|
Explain your question clearly and post your code snippet
To learn all there is to know. I know I'll be disappointed one day, but I've made a good start, and the eventual disappointment is likely to be brief.
-Roger Wright
Never doubt that a small group of thoughtful, committed people can change the world. Indeed, it is the only thing that ever has.-Margaret Mead
|
|
|
|
|
How can we help?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
|
Hello friends, thanks for your help so far. Please, I developed a chatroom and is working fine. But the challenge here is that:
I placed the repeater control inside a panel control and set the panel scrollbars to auto. But, the panel couldn't scroll to bottom. Please, how can I make the panel control to always scroll to bottom so that users can see the last message? Please render any help. Cheers!!!
|
|
|
|
|
how to define scafolding in mvc?
|
|
|
|
|
|
IS there much difference between ASP.NET or ASP.NET MVC, or many advantages in one over the other?
Ger
Ger
|
|
|
|
|
|
Hello friend's, how is the day going? I need some help here. In my asp.net website, I have fileupload to browse for zip files and save them to a download files folder. The snippet below save uploaded files
--------------------------------------
'get extension type
Dim ext As string=Path.GetFileNameExtension(fileupload1.PostedFile.Filename)
'get filename
Dim filename As string=Path.GetFileName(fileupload1.PostedFile.Filename)
Select Case Ext 'verify file type
Case ".Zip"
'save file to download files folder
fileupload1.SaveAs(Server.MapPath("~/download files/"+ filename))
Case Else
MsgBox("file format not allowed")
End Select
--------------------------------------
the following save the file name to sql Database
Dim constr=("my connection string is here")
Dim con as new SqlConnection(constr)
con.Open()
Dim SaveFile as String="insert into filestbl(filename,desc) values(@filename,@desc)"
Dim cmd as new SqlCommand(SaveFile,constr)
cmd.Parameters.AddWithValue("@filename",filename)
cmd.Parameters.AddWithValue("@desc",txtdesc.Text)
cmd.ExecuteReader
cmd.Dispose
constr.Dispose
constr.Close
----------------------------------
the question is, how can I enable visitors to specify a folder, and code the download button so that the selected file can be downloaded to a folder specify by the person downloading the file. Note, I bind the filestbl to DatalistControl. And, when the file is downloaded, the person should be able to unzip it in his/her system just as it is in codeproject. I am doing this with Asp.net. Any help is welcome! Thanks to all.
-- modified 30-Dec-13 15:11pm.
|
|
|
|
|
I'm not sure what you asking entirely but if a user clicks on the link to download your file the browser will ask them where to save it. So, what is your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hello friends, how was the day? Thanks for your helped so far. Please someone should tell me how to count the number of records in sql table. For example if custtbl with columns cusName, cusLoc, has the following records
---------------------------
cusName cusLoc
Tom USA
Patel India
---------------------------
How can I get the total number of records as two from table above and display it on a msgBox using asp.net? Please help.
|
|
|
|
|
Answer 1:
SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM custtbl", databaseConnection);
int count = (int)cmd.ExecuteScalar();
There are a lot of examples on the web on how to write complete data access code in c#. Ask google.
Answer 2: adapt this ASP.Net Message Box Alert Display[^] to display the count value in a message box.
modified 28-Dec-13 10:51am.
|
|
|
|
|
Solved: waoooo Peter! It works like magic. How can I thank you? Well, thank you very much I really I appreciate.
|
|
|
|
|
Glad to hear that my solution helped. Is there a button for you to click to indicate acceptance of solution? I must admit I am still quite new in this neighbourhood.
|
|
|
|
|
Welcome to code project Peter! I love this site. The only indicator I know is to type solved in place of Re:.
|
|
|
|
|
I found it. It says:
"If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.".
Hover over the answer that you want to vote, an up arrow (upvote) and a down arrow (downvote) symbols appear for voting.
modified 29-Dec-13 20:46pm.
|
|
|
|
|
hello
i want to get LatLng (in google map) based on the textbox value.
what do i do?
i have an error when run this cod:
the error is:
Microsoft JScript runtime error: Object required
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>
<script type="text/javascript">
var a=parseInt(document.getElementById("Text1").value);
var b=parseInt(document.getElementById("Text2").value);
var myCenter=new google.maps.LatLng(a,b);
function initialize()
{
var mapProp = {
center:myCenter,
zoom:15,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap")
,mapProp);
var marker=new google.maps.Marker({
position:myCenter,
animation:google.maps.Animation.BOUNCE
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<input id="Text1" type="text" value="36"/>
<input id="Text2" type="text" value="59"/>
<div id="googleMap" style="width:800px;height:500px;"></div>
modified 28-Dec-13 7:57am.
|
|
|
|
|
There are a few mistakes,
1. myCenter is not initialized
2. LatLng should be float type not integer type
3. there should be a function that is activated by say a button click in order to capture the new a and b values upon changes by the user
4. a and b have to be converted to latlng type
5. Spot the rest yourself from my demo code below:
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false">
</script>
<script>
var a;
var b;
var map;
var myCenter=new google.maps.LatLng(a,b);
function initialize()
{
a=parseFloat(document.getElementById("Text1").value);
b=parseFloat(document.getElementById("Text2").value);
var myCenter= new google.maps.LatLng(a, b);
var mapProp = {
center:myCenter,
zoom:8,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map=new google.maps.Map(document.getElementById("googleMap")
,mapProp);
var marker=new google.maps.Marker({
position:myCenter,
animation:google.maps.Animation.BOUNCE
});
marker.setMap(map);
}
function updateLocation(){
a=parseFloat(document.getElementById("Text1").value);
b=parseFloat(document.getElementById("Text2").value);
var latLng = new google.maps.LatLng(a, b); //create a latlng
map.panTo(latLng); //Make map global
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<input id="Text1" type="text" value="1.3520830"/>
<input id="Text2" type="text" value="103.819836"/>
<button onclick="updateLocation()">Update Location</button>
<div id="googleMap" style="width:800px;height:500px;"></div>
</body>
</html>
|
|
|
|
|
thank you very much
I say condolence for the suffering of martyrdom the prophet Mohammad and the Imam Hasan and the Imam Reza to all of the Muslims.
modified 1-Jan-14 11:24am.
|
|
|
|