|
I have a task to dsiplay a report using ASP.NET webforms ReportViewer Control. I am using a localreport mode to display the report.
Now when I change something in the search_str parameter which I want to pass teh value from a textbox prompted to the user and click the View Report button, how to refresh or reset the search_str parameter in the button1_click event.
|
|
|
|
|
It comes from the TextBox's value, whenever the button is clicked, you can remove the value from the TextBox; clear it.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I'm baffled by this.
I wrote a contact us page with a form, that writes the info to the table.
I can read the table, but I can't write to it on the production web server.
I can write to the table on my desktop running VS2013 Debug.
So I have 3 other databases on this production SQL server that works fine.
All the other web sites can read and write to the SQL same server.
It's just my first MVC App, that I wrote.
The function runs from the home controller and returns true, and sends the emails.
In web forms, it throws and exception if there's a mistake, but in my MVC app here, it just runs even if there is an error in the SQL.
Like I said I'm just baffled here on this.
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Contact(ContactModel model, string returnUrl)
{
if (ModelState.IsValid && true == ContactExtender.SubmitContactMessage(model))
{
model.smtp_websiteName = "xxxxxx";
model.smtp_subject = "Contact Us";
model.smtp_sentFrom = "xxxxxx";
model.smtp_sendto = "xxxxxx";
model.smtp_replyto = "xxxxx";
model.smtp_templatePath_website = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/SMTP_Templates/contact_website_template.html");
model.smtp_templatePath_customer = System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/SMTP_Templates/contact_customer_template.html");
bool website = Contact_Website_Email_Proc.Send_XHTML_Website_Message(model);
bool visitor = Contact_Customer_Email_Proc.Send_XHTML_Customer_Message(model);
ViewData["contactMessage"] = "Success";
}
else
{
ViewData["contactMessage"] = "Failed";
}
return View(model);
}
public static bool SubmitContactMessage(ContactModel cm)
{
bool success = false;
string connStr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
SqlConnection conn = new SqlConnection(connStr);
string query =
"INSERT INTO CRM_MESSAGES " +
"( " +
" Name " +
" , Subject " +
" , CompanyName " +
" , EmailAddress " +
" , Query " +
" , Date " +
" , MailingList " +
") " +
"VALUES " +
"( " +
" @Name " +
" , @Subject " +
" , @CompanyName " +
" , @EmailAddress " +
" , @Query " +
" , @Date " +
" , @MailingList " +
") ";
SqlCommand cmd = new SqlCommand(query, conn);
cmd.Parameters.Add(new SqlParameter("@Name", cm.Name));
cmd.Parameters.Add(new SqlParameter("@Subject", "ContactUs"));
cmd.Parameters.Add(new SqlParameter("@CompanyName", cm.CompanyName));
cmd.Parameters.Add(new SqlParameter("@EmailAddress", cm.EmailAddress));
cmd.Parameters.Add(new SqlParameter("@Query", cm.Query));
cmd.Parameters.Add(new SqlParameter("@Date", DateTime.Now));
cmd.Parameters.Add(new SqlParameter("@MailingList", cm.MailingList));
try
{
conn.Open();
cmd.ExecuteNonQuery();
success = true;
}
catch (Exception)
{
success = false;
}
finally
{
conn.Close();
}
return success;
}
|
|
|
|
|
Your execute statement is inside a try\catch block and if an exception is thrown you just return false so you have no idea what the exception is. Either throw the exception again, or at least log the exception details using something like log4net. If you just want a quick diagnosis then remove the try\catch block and re-compile and deploy and you should see the actual error.
|
|
|
|
|
I thought it was pretty straight forward.
I can throw garbage into the SQL statement, and it just runs, with no exception thrown.
So I thought it was a MVC thing. Guess I'll search for exceptions not being thrown in SQL.
I used SqlException as well.
|
|
|
|
|
Well that was weird
I basically did a Easter egg hunt on it.
And tore apart the SQL function.
So I changed the parameters to this format instead. Guess it was my newbie experience in c# that lead to the error.
Now the records write on the production system.
Plus I installed Elmah, to track errors faster.
cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar, 80)).Value = cm.Name;
|
|
|
|
|
Hello ,
I try to add a ModalPopupExtender to my page
i migrate a webpage with a ModalPopupExtender from a web project to another webproject ,
it working in the first project but not working in the new project,
i was add a ajaxtoolkit but still not working , i dont undrestand ,
i create another page with ModalPopupExtender in the new project , its not working ,
but when i copy this same page in the old project it working , i can have a popup ,
please can u tell me what can be it the cause
<body>
<form id="form1" runat="server">
<asp:scriptmanager ID="Scriptmanager1" runat="server" ScriptMode="Release"></asp:scriptmanager>
<div>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1"
PopupControlID="Panel1" X="200" Y="200">
</asp:ModalPopupExtender>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
<asp:Panel ID="Panel1" runat="server" style="display:none;" >
<asp:Label ID="Label1" runat="server" Text="pooooooooooooooop up"></asp:Label>
</asp:Panel>
</div>
</form>
</body>
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
this.ModalPopupExtender1.Show();
}
Thanks
|
|
|
|
|
i was tried all day .. not resolved yet ,
but i was try to install ajax toolkit with nuget , and has an error abaout dependance with html agility ,
|
|
|
|
|
Hello ,
I try to add a ModalPopupExtender to my page
i migrate a webpage with a ModalPopupExtender from a web project to another webproject ,
it working in the first project but not working in the new project,
i was add a ajaxtoolkit but still not working , i dont undrestand ,
i create another page with ModalPopupExtender in the new project , its not working ,
but when i copy this same page in the old project it working , i can have a popup ,
please can u tell me what can be it the cause
<body>
<form id="form1" runat="server">
<asp:scriptmanager ID="Scriptmanager1" runat="server" ScriptMode="Release"></asp:scriptmanager>
<div>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="LinkButton1"
PopupControlID="Panel1" X="200" Y="200">
</asp:ModalPopupExtender>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
<asp:Panel ID="Panel1" runat="server" style="display:none;" >
<asp:Label ID="Label1" runat="server" Text="pooooooooooooooop up"></asp:Label>
</asp:Panel>
</div>
</form>
</body>
protected void Button1_Click(object sender, EventArgs e)
{
Panel1.Visible = true;
this.ModalPopupExtender1.Show();
}
Thanks
|
|
|
|
|
Hi ,
i fount the solution ,
it was a conflict with 2 dll :
Microsoft.ScriptManager.MSAjax.dll
Microsoft.ScriptManager.WebForms.dll
i wish that helps you
|
|
|
|
|
I am using a script manager in one of my master pages in order to load several libraries: jQuery, jQuery UI, and Moment. I set up the mappings in the MapJsLibraries method that is called by the Application_Start method in Global.asax :
Private Sub MapJsLibraries()
With ScriptManager.ScriptResourceMapping
.AddDefinition("jQuery", Nothing, New ScriptResourceDefinition With {.Path = "~/scripts/jquery-2.1.3.min.js",
.DebugPath = "~/scripts/jquery-2.1.3.js",
.CdnPath = "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js",
.CdnDebugPath = "https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js",
.CdnSupportsSecureConnection = True})
.AddDefinition("jQueryUI", Nothing, New ScriptResourceDefinition With {.Path = "~/scripts/jquery-ui-1.11.3.min.js",
.DebugPath = "~/scripts/jquery-ui-1.11.3.js",
.CdnPath = "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js",
.CdnDebugPath = "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js",
.CdnSupportsSecureConnection = True})
.AddDefinition("Moment", Nothing, New ScriptResourceDefinition With {.Path = "~/scripts/moment-2.9.0.min.js",
.DebugPath = "~/scripts/moment-2.9.0.js",
.CdnPath = "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.min.js",
.CdnDebugPath = "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment.js",
.CdnSupportsSecureConnection = True})
End With
End Sub
In my master page I have the script manager control:
<asp:ScriptManager runat="server" ID="MasterScriptManager" ClientIDMode="Static" EnablePageMethods="true" EnablePartialRendering="true" EnableCdn="true">
<Scripts>
<asp:ScriptReference Name="jQuery" />
<asp:ScriptReference Name="jQueryUI" />
</Scripts>
</asp:ScriptManager>
However if I view the source of my page (regardless if it is in Debug or Release mode) the scripts are linked as:
<script src="../scripts/jquery-2.1.3.js" type="text/javascript"></script>
<script src="../scripts/jquery-ui-1.11.3.js" type="text/javascript"></script>
<script src="../scripts/moment-2.9.0.js" type="text/javascript"></script>
But the framework scripts are loaded from the CDN:
<script src="https://ajax.aspnetcdn.com/ajax/4.5.1/1/MicrosoftAjaxWebForms.debug.js" type="text/javascript"></script>
<script type="text/javascript">
(window.Sys && Sys.WebForms)||document.write('<script type="text/javascript" src="/ScriptResource.axd?d=T5IBtM-HcRERfDQDXGqZ1FhUIPtFDfyYyY6-gVbY9PxN2FLZSokqO1WuxmLK3n8W3rayqDSC40u1y26T6UCW25sOnNY2_5YE_oh2C9aHsvQssjf0qOsBc-FKfCKa3LgzwYkyEtanyaEjU4NjiWtEHktP89KX6RE6XVFfM-IZFflIST5rif3OlVEjHQMyAxN20&t=fffffffffbd5809e"><\/script>');
</script>
My understanding of the script resource definitions was to be able to allow the script manager to load additional javascript files from a CDN path and, if it wasn't available, fallback on a local copy (as well as autoselecting the debug or release [minified] version).
I have tried modifying this code as well as trying the debug and release modes, but only the local, debug (non-minified) javascript files are loaded. Can anybody provide any suggestions on resolving this as I have several other javascript files that I would like to include?
BTW I have also already confirmed that the CDN paths are valid, I have tried the definitions with and without Nothing being passed for the assembly name, and I have already tried completing removing the Path and DebugPath properties and simply including a resource name. The site is running under .NET 4.
Thank you in advance.
A black hole is where God tried to divide by zero.
There are 10 kinds of people in the world; those who understand binary and those who don't.
|
|
|
|
|
Hello everyone,
I need to create a new empty web site project with visual studio and create a form page with the following fields:
serial number
first name
last name
e-mail address (with regular expression validator)
phone number
Until here i know how to do...but than i need to:
pass the parameters that has been received to the following web function: https://dextertest.eset.com/Dexterdev/Services/serialnumberservice.asmx?op=RegisterSerialNumberNewLicence and in addition, the following parameters as well: an empty string for the parameters: companyName, note, and
the value 39 for countryId parameter.
if the error that has returned==0, it is needed to save the follwing data in a database and present them:
User Name
Password
expiry date
price
serial number
first name
last name
e-mail
phone
otherwise,
the reason of the error need to be presented with the help of the following web function: https://dextertest.eset.com/Dexterdev/Services/ProductService.asmx?op=GetErrorName
*there is also need to be an option to view the Database's data.
I am adding a list of 10 serial numbers for one time usage. The mission has to be done with them:
HDAP-W333-AAE8-8SNP-RSUA
HDAP-W333-AAFT-T52W-AD8P
HDAP-W333-AAK8-8R84-WW37
HDAP-W333-AAKF-F9BA-HRJ8
HDAP-W333-AAVM-M9S8-FKUR
HDAP-W333-ACMK-KE5X-NTV4
HDAP-W333-ACUD-DMER-56MC
HDAP-W333-ACVV-V944-52EB
HDAP-W333-AEGN-N7X7-TFS7
HDAP-W333-AEXW-WCUV-XSNH
Thank you from the buttom of my heart to anyone who helps!!!
God will bless you .
A.T
|
|
|
|
|
Everybody wants to help, but you haven't said what your problem is. Please give a specific question.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I've some ASP.NET Projects previously they were working fine. But after few months after re-installing windows, When I tried to open them in visual studio 2013. I'm getting this error message
An attempt to attach an auto-named database for file ***.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
I've checked the path of *.mdf file which is correct, But still I'm getting this error message. Previously When I tried to open my old projects I did't had any problem, I just used to check the path and that's all. I'm encountring this problem for the first time. Please tell me how can I fix it
Here is the link for the project
http://www.mediafire.com/download/5akd37d48k95gip/Timer.rar</pre>
|
|
|
|
|
when i host my application in iis local host but on the same computer it is open very slow but when open in client computer it works fine any solution please give me ans
|
|
|
|
|
I have written a blog post[^], for ASP.NET developers to read about writing responses and HTML attributes in ASP.NET back-end codes. Might be helpful for others too.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
But you are not supposed to advertise them in the forums.
|
|
|
|
|
Oh, my apologies Richard, I thought we can share the blog posts too. The post is less than 1000 words so it won't be shared on the CodeProject itself.
If this is to be considered as advertisement and/or spam, then sorry, I won't post such content again. Sorry again.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
You can get your blog posts fed in automatically: http://www.codeproject.com/info/Submit.aspx#Blogs[^]. Alternatively you could post it manually as a Tip. The problem with messages such as you posted, is that they tend to push the questions off the screen, so reducing the chance that they will get answered.
|
|
|
|
|
Well, I will remember doing so from now on.
Infact, if there wasn't your message I would have delete the thread and posted it as a tip instead.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I thought so, you are a quick learner. Your contributions to CodeProject are not going unnoticed.
|
|
|
|
|
Might be worth covering boxing when using string.Format (and how to avoid it for a performance gain) and also the string.Concat and StringBuilder options which will perform better, especially StringBuilder when doing a lot of concatenations.
|
|
|
|
|
I would personally suggest StringBuilder; while updating the content of it.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
i have a project mvc3 website shoe.
i use vs 2013 .i cant open it .I debug error.
Warning 2 Could not resolve this reference. Could not locate the assembly "System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. Shoe
plz help me
|
|
|
|
|
That means the library is not found in your project. The library WebPages is responsible for the WebPages framework, it has nothing to do with the MVC, (if in case you're enabling the Web Pages framework too).
Either remove the code that requires this framework, or add this framework from NuGet galleries[^].
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|