I am trying to setup multiple applications within IIS, single server. I want all to use port 80 and the server has only one IP address. I have created two application (site1 and site2) within IIS and modified the 'Host name' under bindings on each as follows: site1.mywebsite.com site2.mywebsite.com

and kept the IP address and port values to be 'All unassigned' and '80' respectively.

I have "mywebsite.com" through godaddy, and not sure how should I configure dns zone file to take this into effect. Please help....

(My ultimate objective is to have n+1 sites hosted in the same server, so that site1.mysite.com through siten.mysite.com points to their respective application, and every other subdomain points to n+1 th application.

Is this a possibility?)

Thanks in advance, Anuruddha

I have two dropdowns. First is for State and second is one for the City. When I select the state, its respective city gets populated in the next dropdown. I have one option to add more cities through textbox on button click while selecting the Other option from the city dropdownlist.

The issue is that whenever i am adding the city from the textbox, the it gets inserted into the respective state and also the dropdownlist loses its value. I tried debugging but couldn't find the exact issue.

Please see the code for your reference:

protected void btnAddDropDown_Click1(object sender, EventArgs e)
{
    using (SqlConnection con = new SqlConnection(constring))
    {
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "Add_CityforLocation";
        cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = 0;
        cmd.Parameters.Add("@CountryName", SqlDbType.VarChar).Value = "India";
        cmd.Parameters.Add("@CityName", SqlDbType.VarChar).Value = txtOtherCity.Text.Trim();
        cmd.Parameters.Add("@StateName", SqlDbType.VarChar).Value = ddllocation1.SelectedItem.ToString();
        cmd.Connection = con;
        try
        {
            cmd.ExecuteNonQuery();
            BindContrydropdown();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);//You Can Haave Messagebox here
        }
        finally
        {
            con.Close();
        }
    }
}

protected void BindContrydropdown()
{
    //conenction path for database
    //string connection = WebConfigurationManager.ConnectionStrings["myconn"].ConnectionString;
    using (SqlConnection con = new SqlConnection(constring))
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("Select Id,CityName From Career.Location", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        ddllocation1.DataSource = ds;
        ddllocation1.DataTextField = "CityName";
        ddllocation1.DataValueField = "Id";
        ddllocation1.DataBind();
        ddllocation1.Items.Insert(0, new ListItem("--Select--", "0"));
        ddllocation1.Items.Insert(1, new ListItem("--OTHER--", "0"));
        con.Close();
    }
}

Also, see the HTML for the same:-

 <tr>
        <td class="td">Location/State</td>
        <td>
            <asp:DropDownList CssClass="txtfld-popup" ID="ddllocation1" OnSelectedIndexChanged="ddllocation1_SelectedIndexChanged" runat="server" AutoPostBack="true"></asp:DropDownList>
            <asp:RequiredFieldValidator CssClass="error_msg" ID="RequiredFieldValidator1" ControlToValidate="ddllocation1" runat="server" ErrorMessage="Please enter location" InitialValue="--Select--" SetFocusOnError="true"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td class="td">Location/City</td>
        <td>
            <asp:DropDownList CssClass="txtfld-popup" ID="ddlLocation" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged"></asp:DropDownList>
            <asp:RequiredFieldValidator CssClass="error_msg" ID="reqLocation" ControlToValidate="ddlLocation" runat="server" ErrorMessage="Please enter location" InitialValue="--Select--" SetFocusOnError="true"></asp:RequiredFieldValidator>
        </td>
    </tr>
    <tr>
        <td>
            <asp:TextBox ID="txtOtherCity" runat="server" Visible="false" CssClass="txtfld-popup"></asp:TextBox>
            &nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnAddDropDown" runat="server" Width="63" Text="Add" CausesValidation="false" OnClick="btnAddDropDown_Click1" />
        </td>
    </tr>

I have couple of dropdown lists to filter data from gridview which works fine but I want to add Select Any where it shows the data without the filter.

http://i.imgur.com/zwIw23t.jpg

This is my SelectCommand in SQL datasource

SelectCommand="SELECT * FROM [Courses]
WHERE (([Language] = @Language) AND ([Level] = @Level)       
AND ([endDate] = @endDate) AND ([startDate] = @startDate))"

I am unable to see _admin page in Web Matrix. i already contain a *.cshtml file in root. Also my nuget package manager keeps on uninstalling itself please help me i am new with all this.

I have a webservice that I need to consume files from. The problem is this webservice limits API calls to 100MB but the files are larger then 100MB. So they recommended we use the the Range header. I added the range to the HttpWebRequest. My problem seems to be combining the Streams. I think it stems from the fact that I cannot create a instance of the ConnectSream (which I think is what GetResponseStream returns). So I have to create a MemoryStream instead. Except when I do it this way I try to open a test zip file I uploaded it wont open. How can I fix this so I can combine the two streams and then save the file to the disk?

foreach (var largeFile in LargeFilesToDownload)
{
    Stream stream = new MemoryStream();

    while (endSize <= largeFile.Value)
    {
        try
        {
            HttpWebRequest downReq = (HttpWebRequest)HttpWebRequest.Create("https://webserviceurl/" + largeFile.Key);
            downReq.Headers.Add("Authorization", "Bearer " + API_TOKEN);
            downReq.AddRange(startSize, endSize);
            downReq.Method = "GET";
            using (var eresp2 = (HttpWebResponse)downReq.GetResponse())
            {
                eresp2.GetResponseStream().CopyTo(stream);
            }
        }
        catch (Exception exc)
        {
            //Handle Exception
        }
        //Set new startSize and endSize here
    }

    try
    {
        //check to make sure path exists here

        string path = SaveLocation + @"\" + rootDir + @"\" + Path.GetFileName(largeFile.Key);

        using (FileStream file = new FileStream(path, FileMode.Create, System.IO.FileAccess.Write))
        {
            byte[] bytes = new byte[stream.Length];
            stream.Read(bytes, 0, (int)stream.Length);
            file.Write(bytes, 0, bytes.Length);
            stream.Close();
        }
        FilesToDelete.Add(largeFile.Key);
    }
    catch (Exception ex2)
    {
        //Handle Exception
    }
}

In my ASP.NET VB project, I'm using the same DB connection to run several methods, including update, insert and delete.

The insert and delete work fine, however the update doesn't work. I've tried changing around the string to no avail, using string.format and other similar methods.

The string should work, when inserted directly into SQL management studio, it works correctly.

strData = "Update tblSkiOffers SET ResortID = " & drpResort.SelectedValue
strData &= ", Tag1 = '" & txtTag1.Text & "', Tag2 = '" & txtTag2.Text & "', Tag3 = '" & txtTag3.Text & "', Image = '" & txtImage.Text & "',"
strData &= "OldPrice = " & txtOldPrice.Text & ", NewPrice = " & txtNewPrice.Text & ", VisitTime = '" & drpTimeOfYear.SelectedValue.ToString() & "',"
strData &= "Year = " & drpYear.SelectedValue.ToString() & " Where OfferID = " & offerid


Dim DBCon As New SqlConnection(ConfigurationManager.AppSettings("DBCon"))
Dim myCommand As New SqlCommand(strData, DBCon)

DBCon.Open()

myCommand.ExecuteReader(CommandBehavior.CloseConnection)

DBCon.Close()
Response.Redirect("Default.aspx")

Being passed is:

Update tblSkiOffers SET ResortID = 8, Tag1 = ' asdsdfsdfasd', Tag2 = ' asdsdfsdfasd ', Tag3 = 'asdassdfsdfd', Image = ' asdasd ',OldPrice = 666.00, NewPrice = 454.00, VisitTime = 'Summer',Year = 2014 Where OfferID = 24

I have googled this all morning but could not resolve it.

Infact, the solution I am trying below was extracted from this site:

 If e.Row.RowType = DataControlRowType.DataRow Then
 Dim eDate As TextBox = DirectCast(e.Row.FindControl("txtEventDate"), TextBox)
 eDate.Text = Request.QueryString("evdates")
 DateTime.ParseExact(eDate.Text, "MM/dd/yyyy", CultureInfo.CurrentCulture)
End If

The date value displays as 14/04/2014 00:00:00 but we would like to display as MM/dd/yyyy.

But we keep getting String was not recognized as a valid DateTime.

I even tried doing this on the markup but to no avail.

<asp:TextBox ID="txtEventDate" DataFormatString="{0:d}" runat="server"></asp:TextBox>

Any ideas how to fix this?

So I can't seem to find anywhere how to do this. I want to be able to use the value of BuyOutPrice in the text(confirm) box but can't seem to make it work.

More specificly, how am I supposed to write this part: ('Are you sure you want to buy-out for $' + BuyOutPrice + '?')

This was just my closest guess from experience in other programming languages but it appears invalid in JavaScript.

var BuyOutPrice = '<%= Content.ComparisonPrice %>';


<asp:ImageButton ID="BuyNowButton" OnClick="BuyNowButton_Click" Style="vertical-align:top;" ImageUrl="Images/btn_buyNow.png" runat="server" OnClientClick="javascript:return confirm('Are you sure you want to buy-out for $' + BuyOutPrice + '?'); BuyNow(); return ValidateBuyNow();" />

I have been using Kendo UI in my asp.net MVC4 project, and it works normally.

I have used widgets like DropDownList, Grid, and it has no problem.

Recenetly I would like to change some of my DropDownList to MultiSelect,

so I try to copy the example in this link: MultiSelect Basic Usage

However, an error message is shown:

CS1061: 'Kendo.Mvc.UI.Fluent.WidgetFactory<XXX>' does not contain a definition for 'MultiSelect' and no extension method 'MultiSelect' accepting a first argument of type 'Kendo.Mvc.UI.Fluent.WidgetFactory<XXX>' could be found (are you missing a using directive or an assembly reference?) XXX is the model passed into that View.

I have google it and it seems like a problem about the namespace / reference config, yet as I said, I have used other Kendo UI widget normally...

Below is my code of my WORKING DropDownList, and a not working MultiSelect

@(Html.Kendo().DropDownList()
       .Name("vendorName") // Name of the widget should be the same as the name of the property
       .DataValueField("VendorCategoryID") // The value of the dropdown is taken from the EmployeeID property
       .DataTextField("VendorName") // The text of the items is taken from the EmployeeName property
       .DataSource(source =>
            {
                source.Read(read =>
                {
                    read.Action("GetVendors", "GenReport"); //Set the Action and Controller name
                });

            })
            .OptionLabel("---Please Select---")
            .Events(e =>
                {
                    e.Change("vendorOnChange");
                })
)

@(Html.Kendo().MultiSelect()
      .Name("required")
      .Placeholder("Select attendees...")
      .BindTo(new List<string>() {
          "Steven White",
          "Nancy King",
          "Anne King",
          "Nancy Davolio",
          "Robert Davolio",
          "Michael Leverling",
          "Andrew Callahan",
          "Michael Suyama",
          "Anne King",
          "Laura Peacock",
          "Robert Fuller",
          "Janet White",
          "Nancy Leverling",
          "Robert Buchanan",
          "Andrew Fuller",
          "Anne Davolio",
          "Andrew Suyama",
          "Nige Buchanan",
          "Laura Fuller"
      })
      .Value(new string[] { "Anne King", "Andrew Fuller" })
)

Here is the Intellisense of my VS2012, no MultiSelect... enter image description here

Can anyone help me out and tell me how can I use the MultiSelect? Thanks!

I want to perform validation without using Data Annotation as i have used EF in n-tier MVC 4 razor architecture. And also Data Annotations doesn't work for EF controls.You all can see my code here:

[HttpPost]
public ActionResult RegisterNewUser(CreateUser obj)
{
    if (ModelState.IsValid)
    {
        //    
    }
}

and ModalState.Isvalid doesn't work. How can I resolve this?

I am new to asp .net MVC 4.

I am doing a small application. I have one check box, once I will click on that check box then I should able to display two text box. I have made them these two text box as invisible with the help of display:none

Coding

<script type="text/javascript">
       $(document).ready(function () {
         $('#checkbox1').click(function setCompleteStatus() {
            $('#textboxshow').show();
         });
      });


 <tr class="gridAlternateRow">
      <td>
       <span style="color:red;">*</span>&nbsp;Name
      </td>
      <td colspan="4">
          <div class="row">
               @Html.TextBoxFor(m=>m.txtfirstName)
                 <br />
                  @Html.CheckBox("txtChangePrintName", new { @id = "checkbox1", @onclick = "setCompleteStatus()" })
                        <br />
                   <div id="textboxshow">
                        @Html.TextBoxFor(m => m.txtfirstName, new { style = "display:none;", @readonly = "readonly" })
                        @Html.TextBoxFor(m => m.txtLastName, new { style = "display:none;" })
                  </div> 
         </div>
     </td>
</tr>

As I am new to mvc 4 so I am not able to do ? Will any one help me out ?

I need to trigger submit on a form where there is no input textbox. It has a date range selection and a submit button. On changing the date and pressing on enter key it should repopulate my data.I have tried setting default button and using

$("#MainForm").keypress(function(e) , unfortunately both are not working.
@using (Html.BeginForm("a", "a", FormMethod.Post, new { @id = "RepForm", defaultButton = "SubmitButton"}))
<button id="daterangepicker2"></button>      
<input type="submit" value="SubmitButton" class="btn-primary btn" id="SubmitButton"/>
 $(document).ready(function() {  $("#RepForm").keydown(function (e) { if (e.which == "13") { var defaultButtonId = $("#RepForm").attr("defaultbutton");  $("#" + defaultButtonId).click(); }});

The problem I am facing is this:

<div data-role="footer">
    <a class="ui-btn" href="RV2.cshtml">Anchor</a>
    <p>THINGS WRITTEN IN FOOTER</p>
</div>

In href, I am passing the name of file as it is, because RV2.cshtml is in Views folder and this file, from which I am calling RV2, is also in Views folder. But its not working this way. I have to put RV2.cshtml in Assets folder and then this HTML link starts working.

Why is that?? And I want all my views in Views folder not in Assets folder. What should I do to achieve that??

Here is the snapshot of folders:

enter image description here

Now this works fine.

But I want it the following way:

enter image description here

I have an mvc architecture using requireJS within my app. Now I have the case where I want to check for changes within my model. If changes on the internal structure changed, I want to notify the view. The internal structure for instance look like this:

{
  name: "Christian",
  number: "555-1548",
  age: 30
}

I've seen frameworks like watch.JS, but now the tricky part.. I don't want to use getter and setter AND it must run on IE 8. Is there any lib available that just gives me the opportunity to watch for changes within objects like watch.js does? Any technic or any suggestion?

My program is working but jsp page loading very slow that is my issue , i am passing empid and image name as a parameter from a jsp page to a servlet which i am able to do perfectly and it is receiving in servlet and calling data access class associated method after that i am retrieving it and passing all this to jsp in jsp i am using scriptlet inside that i am doing java coding the image is loading into jsp page but it is loading very slow at least 10-15 second and console showing some error EVERE: Servlet.service() for servlet [jsp] in context with path [/MVCDemoProject] threw exception [java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause java.lang.IllegalStateException: getOutputStream() has already been called for this response so please anyone help ,e here...

EmployeeBean class method

  public Employee RetrieveImg(Employee emp1){
  Connection con = null;
  Statement stmt = null;
  PreparedStatement pstmt = null;
  ResultSet rs = null;
  byte[] sImageBytes;
  int z = emp1.getEmpId();
  String q = emp1.getIname();
  try {
   int count =0;
     con = ConnectionManager.getConnection();
     stmt = con.createStatement();
     String Query ="SELECT photo FROM upload_documets WHERE empId ='"+z+"' and Name ='"+q+"'";
     rs = stmt.executeQuery(Query);
           if(rs.next()) 
       {          sImageBytes = rs.getBytes(1);
                  emp1 = new Employee();
                  emp1.setFileBytes(sImageBytes);
               emp1.setValid1(true);     
       } 
  }catch (SQLException  ex) {

       } finally {
           try {
               if (stmt != null) {
                   stmt.close();
               }
               if (con != null) {
                   con.close();
               }
           } catch (SQLException ex) {
            Logger.getLogger(EmployeeBean.class.getName()).log(Level.SEVERE, null, ex);
           }
       }
    return emp1;
   }

Image retrieval servlet where we are calling data access class(employee bean) method on the basis of input which we have received from jsp page image name and emp id name

   @WebServlet(name = "Retrieve_Image", urlPatterns = {"/Retrieve_Image"})
   public class Retrieve_Image extends HttpServlet {
   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    HttpSession session = request.getSession(true); 
Employee emp1 = (Employee)session.getAttribute("emp1");

    String iname = request.getParameter("iname");
    emp1.setEmpId(emp1.getEmpId());
    emp1.setIname(iname);
    EmployeeBean eb = new EmployeeBean();
    eb.RetrieveImg(emp1);
    if(emp1.isValid1())
    {
         response.sendRedirect("Image.jsp");
    }

}

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
}

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
}

@Override
public String getServletInfo() {
    return "Short description";
  }
 }

jsp page after calling method where we want to see image response should come ..

 <body>

 <%
Employee emp1 = (Employee)session.getAttribute("emp1");
 session.setAttribute("emp1",emp1);

   byte[] sImageBytes;
   try{
  sImageBytes = emp1.getFileBytes();

  response.setContentType("image/jpeg");
   response.setContentLength(sImageBytes.length);
 response.setHeader("Content-Disposition", "inline; filename=\"");

 BufferedInputStream  input = new BufferedInputStream
 (new ByteArrayInputStream(sImageBytes));
    BufferedOutputStream output =
   new BufferedOutputStream(response.getOutputStream());

  byte[] buffer = new byte[8192];
   int length;
    while ((length = input.read(buffer)) > 0) {
 output.write(buffer, 0, length);
}
 }
  catch(Exception ex){
  System.out.println("error :"+ex);
    }
 %>

 </body>
  </html>

I am using trirand jqgrid mvc.I am having jqgrid with group level data and i can edit for only row level but i want it for both group level edit(delegate and reject) and row level edit .Update to database.like below image.enter image description here

The execution steps in angular that known by me is like this:

  1. load defined modules.
  2. initialize the injector.
  3. compile the html inside the [ng-app] tag.

Then if i want to load module after these three steps,seems i'd have to execute these three steps again.But i don't know how to exactly do it :-( Any good solutions?thanks very much!

PS:The 'module' i mentioned is defined by angular.module() method.

I have to populate the checkboxes on a page from the database. I am using an AJAX get method for fetching the record ID and it's corresponding right in a hash,

CoffeeScript:

$ ->
$(document).ready ->
 $.get('/server_management/getpair/').success (data) ->
   alert(data.toString()) # Shows nothing
   console.log(data) # Shows the HTML of the entire page

Controller:

 def getpair

 pair = UserServer.getpair
 render :nothing => true

 end

Model:

 def self.getpair

 UserServer.find_each do |us|
    if us.user_id == @uid # @uid is getting its value in another UserServer method
       pair[us.server_id] = us.right
    end
 end
 gair = pair # Just for the sake of 'last-assignment-is-a-return-in-ruby' thingy

 end

Now the problem is that the AJAX get is showing "Status Code:304 Not Modified" and the console.log(data) shows the HTML of the page.

I will be grateful for any help.

How to print image from current path in MVC app on button click open dialog box with printing options like in office

I am trying to set the default Value of a field in an ASP.net MVC web application.

I am using database first so I have added a partial class for meta data as follows:

[MetadataType(typeof(RadioRoutingMetadata))]
public partial class RadioRouting
{
}

public partial class RadioRoutingMetadata
{
    [DefaultValue("%")]
    public string Slot { get; set; }

    [Required(ErrorMessage = "This field is requied")]
    [DefaultValue(0)]
    public int BlockStart { get; set; }

    [Required(ErrorMessage = "This field is requied")]
    [DefaultValue(499)]
    public int BlockEnd { get; set; }

    [DefaultValue(-1)]
    public int FallBackBaseIdentifier { get; set; }
}

No after reading I see that [DefaultValue(T)] doesn't initialise the field to that value when being created. But do the Html helper methods not look at this field?

here is my view:

<p>
   @Html.LabelFor(model => model.Slot, htmlAttributes: new { @class = "control-label col-md-2" })
   <span class="field">
       @Html.EditorFor(model => model.Slot, new { htmlAttributes = new { @class = "form-control" } })
       @Html.ValidationMessageFor(model => model.Slot, "", new { @class = "text-danger" })
   </span>
</p>

<p>
    @Html.LabelFor(model => model.BlockStart, htmlAttributes: new { @class = "control-label col-md-2" })
    <span class="field">
        @Html.EditorFor(model => model.BlockStart, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.BlockStart, "", new { @class = "text-danger" })
    </span>
</p>

<p>
    @Html.LabelFor(model => model.BlockEnd, htmlAttributes: new { @class = "control-label col-md-2" })
    <span class="field">
        @Html.EditorFor(model => model.BlockEnd, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.BlockEnd, "", new { @class = "text-danger" })
    </span>
</p>

So When I now provide a Create Form I want these default values to be there in the form.

Do I have to initialize the Model object in the controller, set the default values, and then pass it through to the create view as if it was an edit view?

If so how can I create a constructor that initializes all the default values in the partial class?

I try to export chart images to png or pdf with the code below.(I use Asp.Net MVC, Telerik Kendo, Inskcape)

Every user needs to have installed Inkscape software on their computers to get charts exported. I mean, if user doesn't have Inkscape, user can not get image.

So i want to control if user have Inkscape or not. If there is no installed Inkscape, i want to show exception message to related View like "Please install Inkscape to your computers"

How can i do it? With try, catch? If else? I can't get the logic about what i should.

  private string DoExport(string svgFile, KendoChartExport.Models.ExportFormat format)
        {

            var extension = format == KendoChartExport.Models.ExportFormat.PNG ? "png" : "pdf";
            var outFile = TempFileName() + "." + extension;
            var inkscape = new System.Diagnostics.Process();
            inkscape.StartInfo.FileName = INKSCAPE_PATH;
            inkscape.StartInfo.Arguments =
                String.Format("--file \"{0}\" --export-{1} \"{2}\" --export-width {3} --export-height {4}",
                              svgFile, extension, outFile, WIDTH, HEIGHT);
            inkscape.StartInfo.UseShellExecute = true;
            inkscape.Start();
            inkscape.WaitForExit();

            return outFile;
        }

I want to someting like that:

   try
            {
                 inkscape.Start();
            }
            catch (Exception)
            {

                throw ViewBag.Error = "Please Install Inkscape";
            }

Any idea to help?