|
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 !~
|
|
|
|
|
I am looking for some help, I want to add paging in datalist on my client's website, the code is as follows: If you required any other information or need files to review the html and code file please mention
aspx page
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" RepeatDirection="Horizontal">
<ItemTemplate>
<asp:ImageButton ID="img_product" runat="server" ImageUrl='<%# Eval("it_pic1_s") %>' Height="214px" Width="196px" BorderColor="#E0E0E0" BorderStyle="Solid" BorderWidth="1px" /><br />
<asp:Label ID="lbl_code" runat="server" Text='<%# Eval("it_code") %>' Font-Bold="True"></asp:Label><br />
<asp:Label ID="lbl_name" runat="server" Text='<%# Eval("it_name") %>'></asp:Label><br />
Old Price USD
<asp:Label ID="lbl_old_price" runat="server" Text='<%# Eval("old_price") %>'></asp:Label>/pc
<br />
<strong>New Price USD</strong>
<asp:Label ID="lbl_new_price" runat="server" Text='<%# Eval("new_price") %>' ForeColor="Maroon"></asp:Label>/pc
<br />
<asp:ImageButton ID="img_button" runat="server" ImageUrl="~/images/leather-shop_52.jpg" />
</ItemTemplate>
<SeparatorStyle BackColor="White" BorderColor="White" />
</asp:DataList> </div>
Code file:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim cn1 As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("~\App_Data\order_database.mdb"))
Dim varProduct As String
varProduct = "leather jacket"
Dim varQty = 0
Dim query1 = "select it_code, it_name, it_qty, it_pic1_s, old_price, new_price from item_stock where it_keywords LIKE '%" & varProduct & "%' AND it_qty = '" & 1 & "'"
Dim da1 As New OleDbDataAdapter(query1, cn1)
Dim ds1 As New DataSet
da1.Fill(ds1, "item_Stock")
If ds1.Tables(0).Rows().Count() >= 1 Then
Me.DataList1.DataSource = ds1
Me.DataList1.DataBind()
Dim lbl_old_price As Label = CType(FindControl("lbl_old_price"), Label)
Dim lbl_new_price As Label = CType(FindControl("lbl_new_price"), Label)
Dim lbl_code As Label = CType(FindControl("lbl_code"), Label)
Dim lbl_name As Label = CType(FindControl("lbl_name"), Label)
Dim img_product As ImageButton = CType(FindControl("img_product"), ImageButton)
End If
Dim cbrowser = (Request.ServerVariables("http_user_agent"))
Dim clientip = (Request.ServerVariables("remote_addr"))
Dim cdnsip = (Request.ServerVariables("remote_host"))
Dim varCartStatus = "1"
Dim cmda5 As OleDbCommand = New OleDbCommand("Select Count(id) from shopping_cart where client_browser = '" & cbrowser & "' AND client_ip = '" & clientip & "' AND cart_status = '" & varCartStatus & "'", New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~\App_Data\order_database.mdb")))
cmda5.Connection.Open()
Dim count As Integer
count = cmda5.ExecuteScalar()
If count > 1 Then
Me.lbl_count.Text = "Items[" & count & "]"
Else
Me.lbl_count.Text = "Item[" & count & "]"
End If
cmda5.Connection.Close()
End If
End Sub
|
|
|
|
|
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
|
|
|
|
|
Public Sub ia()
end sub
i just want to call this function in side javascript code ?
|
|
|
|
|
You would have to put your VB code into a webservice or into something (like a page) that JavaScript can call.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have several fieldnames from the database, one form field from markup called ddlPartySize.SelectedValue and one variable from codebehind.
I am trying to form a hyperlink on code behind but getting End of Statement Expected error message.
Any ideas how to resolve this?
Thanks in advance:
Private Sub gvCustomers_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCustomers.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim hl As HyperLink = CType(e.Row.FindControl("hdReserve"), HyperLink)
If hl IsNot Nothing Then
hl.NavigateUrl = "<%# String.Format("ReserveFacility.aspx?id={0}&groupsize={1}&facilityFees={2}&depoitAmt={3}&cancelAmt={4}&keydeptAmt={5}&extrahour={6}&hoursdiff={7}", CType(Container.DataItem, System.Data.DataRowView)("siteId") , ddlPartySize.SelectedValue,CType(Container.DataItem, System.Data.DataRowView)("RentalFeeAmount"),CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"),CType(Container.DataItem, System.Data.DataRowView)("CancellationAmount"),CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"),CType(Container.DataItem, System.Data.DataRowView)("ExtraHourAmount"),hourDiff %>"
End If
End If
End Sub
I use the code on markup below, it works except hourDiff from ValidateDuration sub on codebehind.
<asp:TemplateField HeaderText="Select" SortExpression="siteid">
<ItemTemplate>
<asp:HyperLink ID="hdReserve" class="js_siteid" AutoPostBack="false" runat="server" Text="Select"
Navigateurl='<%# String.Format("ReserveFacility.aspx?id={0}&groupsize={1}&facilityFees={2}&depoitAmt={3}&cancelAmt={4}&keydeptAmt={5}&extrahour={6}", CType(Container.DataItem, System.Data.DataRowView)("siteId") , ddlPartySize.SelectedValue,CType(Container.DataItem, System.Data.DataRowView)("RentalFeeAmount"),CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"),CType(Container.DataItem, System.Data.DataRowView)("CancellationAmount"),CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"),CType(Container.DataItem, System.Data.DataRowView)("ExtraHourAmount")) %>' />
</ItemTemplate>
</asp:TemplateField>
|
|
|
|
|
I expect you need to escape some quotes, but that's just a guess.
|
|
|
|
|
You have a combination of incorrect quotes and a missing closing parenthesis.
Try something like this:
<asp:TemplateField HeaderText="Select" SortExpression="siteid">
<ItemTemplate>
<asp:HyperLink ID="hdReserve" class="js_siteid" AutoPostBack="false" runat="server" Text="Select"
NavigateUrl='<%# String.Format("ReserveFacility.aspx?id={0}&groupsize={1}&facilityFees={2}&depoitAmt={3}&cancelAmt={4}&keydeptAmt={5}&extrahour={6}&hoursdiff={7}", CType(Container.DataItem, System.Data.DataRowView)("siteId") , ddlPartySize.SelectedValue, CType(Container.DataItem, System.Data.DataRowView)("RentalFeeAmount"), CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"), CType(Container.DataItem, System.Data.DataRowView)("CancellationAmount"), CType(Container.DataItem, System.Data.DataRowView)("DepositAmount"), CType(Container.DataItem, System.Data.DataRowView)("ExtraHourAmount"), hourDiff) %>'
/>
</ItemTemplate>
</asp:TemplateField>
If you're using .NET 4.5, you can simplify that code by using a strongly-typed data control[^]. Just add ItemType="System.Data.DataRowView" to your data-bound control, and then replace each instance of:
CType(Container.DataItem, System.Data.DataRowView)("...")
with:
Item("...")
If you're using an earlier version, you could still make the code easier to read by using Eval :
Eval("...")
However, that will perform very slightly slower - you'd need to run some performance tests on your code to see if the difference was a problem.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard, *always* fantastic to hear from you.
That ValidateDuration sub is actually yours you helped me out with sometime last year.
Just a refresher, here it is again:
Protected Sub ValidateDuration(ByVal sender As Object, ByVal args As ServerValidateEventArgs)
Dim validator As Control = DirectCast(sender, Control)
Dim row As Control = validator.NamingContainer
Dim startHour As Integer = Integer.Parse(DirectCast(row.FindControl("startHour"), DropDownList).SelectedValue)
Dim startMinutes As Integer = Integer.Parse(DirectCast(row.FindControl("startMinutes"), DropDownList).SelectedValue)
Dim startAmPm As String = DirectCast(row.FindControl("startAmPm"), DropDownList).SelectedValue
Select Case startAmPm
Case "AM"
If True Then
If startHour = 12 Then
startHour = 0
End If
Exit Select
End If
Case "PM"
If True Then
If startHour <> 12 Then
startHour += 12
End If
Exit Select
End If
Case Else
If True Then
args.IsValid = True
Return
End If
End Select
Dim endHour As Integer = Integer.Parse(DirectCast(row.FindControl("endHour"), DropDownList).SelectedValue)
Dim endMinutes As Integer = Integer.Parse(DirectCast(row.FindControl("endMinutes"), DropDownList).SelectedValue)
Dim endAmPm As String = DirectCast(row.FindControl("endAmPm"), DropDownList).SelectedValue
Select Case endAmPm
Case "AM"
If True Then
If endHour = 12 Then
endHour = 0
End If
Exit Select
End If
Case "PM"
If True Then
If endHour <> 12 Then
endHour += 12
End If
Exit Select
End If
Case Else
If True Then
args.IsValid = True
Return
End If
End Select
hourDiff = endHour - startHour
If endMinutes < startMinutes Then
hourDiff -= 1
End If
'Response.Write(hourDiff)
'Response.End()
args.IsValid = hourDiff >= 4
End Sub
I moved hourDiff definiation at class level outside the sub so I can append the value of it to hyperlink control id of hpReserve.
Just having a couple of problems doing so.
One, as you can see, the hourDiff is not a database field. So, I can't use eval(...).
So, it is giving an error that hourDiff is unaccessible.
Second, I keep getting ValidateDuration is undefined when using it to ensure that a minimum of 4 hours is selected.
Any thoughts?
|
|
|
|
|
OK, so it's this thread[^] from back in July?
If you make the hourDiff a public or protected field, it should be available to the data-binding code. However, it won't be populated until the custom validator has run, which isn't going to happen until the user has selected the start and end hours and posted them back to the server.
In this case, building the NavigateUrl on the server isn't going to work. You're going to need some javascript to update the URL on the client.
Start with the fixed elements which you know on the server:
<asp:HyperLink ID="hdReserve" class="js_siteid" runat="server" Text="Select"
NavigateUrl='<%# String.Format("ReserveFacility.aspx?id={0}&facilityFees={1}&depoitAmt={2}&cancelAmt={3}&keydeptAmt={4}&extrahour={5}", Eval("siteId"), Eval("RentalFeeAmount"), Eval("DepositAmount"), Eval("CancellationAmount"), Eval("DepositAmount"), Eval("ExtraHourAmount")) %>'
/>
Then add some javascript to modify the URL when the controls change. Something like this should work:
$(function(){
var parseTime = function(container, prefix){
var hour = parseInt(container.find("select[name$=" + prefix + "Hour]").val(), 10);
var minutes = parseInt(container.find("select[name$=" + prefix + "Minutes]").val(), 10);
var amPm = container.find("select[name$=" + prefix + "AmPm]").val();
switch (amPm) {
case "AM": {
if (hour === 12) { hour = 0; }
break;
}
case "PM": {
if (hour !== 12) { hour += 12; }
break;
}
default: {
return null;
}
}
return { hour: hour, minutes: minutes };
};
$("a.js_siteid").each(function(){
var me = $(this);
var row = me.closest("tr");
var baseUrl = me.attr("href");
row.on("change", "select[name$=ddlPartySize], select[name$=Hour], select[name$=Minutes], select[name$=AmPm]", function(){
var url = baseUrl;
var groupSize = row.find("select[name$=ddlPartySize]").val();
if (groupSize) { url += "&groupsize=" + encodeURIComponent(groupSize); }
var startTime = parseTime(row, "start");
var endTime = parseTime(row, "end");
if (startTime && endTime){
var hourDiff = endTime.hour - startTime.hour;
if (endTime.minutes < startTime.minutes) { hourDiff--; }
url += "&hoursdiff=" + hourDiff.toString();
}
me.attr("href", url);
});
});
});
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks so much sir but there is a little problem though and I suspected we would have this problem as soon as I saw your solution but I wanted to try it anyway.
First, the hyperlink doesn't become exposed to the javascript until after the search button is clicked.
Then it becomes available.
Right now, the groupsize and the hoursdiff do not show up on the hyperlink.
Many thanks sir.
|
|
|
|
|